#!/bin/sh
#
# Configure -- configure lsof
#
# See the LSOF_HLP here document for usage.
#
# See the lsof distribution file 00XCONFIG for information on setting
# environment variables for cross-configuring lsof -- e.g., for configuring
# for Linux 2.3 on a machine running 2.4.  Marty Leisner suggested this
# support and provided the Linux Configure stanza modifications.
#
# When configuring for a particular dialect, <target-dialect>, this script
# requires that the subdirectory ./dialects/<target-dialect> contain a
# shell script, named $LSOF_MK, that places its source modules in this
# directory.
#
# $Id: Configure,v 1.166 2018/07/14 12:13:52 abe Exp $

# LSOF_CFLAGS_OVERRIDE=1 may be introduced through the environment to cause
#	the library Makefile's CFLAGS definition to override any in the
#	environment.

# LSOF_DISTRIBKVM may be introduced through the environment to specify the
#	Sun4 kernel virtual memory type of distrib.cf

LSOF_F="ddev.c dfile.c dlsof.h dmnt.c dnode*.c dproc.c dproto.h dsock.c dstore.c dzfs.h kernelbase.h machine.h machine.h.old new_machine.h __lseek.s"
LSOF_HLP_BASE=./cfghlp.
LSOF_HLP=${LSOF_HLP_BASE}$$

# LSOF_LOCALSUFFIX may be introduced through the environment to select a local
#	version of a Makefile.  It is used as a suffix to $LSOF_MKF.

# LSOF_MAKE may be introduced through the environment to specify a path to the
#	make command.   It defaults to `which make`, if that is non-NULL;
#	otherwise to the string "make".

if test "X$LSOF_MAKE" = "X"	# {
then
  LSOF_MAKE=`which make`
  if test "X$LSOF_MAKE" = "X"	# {
  then
    LSOF_MAKE=make
  fi	# }
fi	# }

LSOF_MK=Mksrc

# LSOF_MKC is the dialect's Mksrc create command -- default "ln -s".

# LSOF_MKFC may be introduced though the environment to change the name
# used for the created make file.

if test "X$LSOF_MKFC" = "X"	# {
then
  LSOF_MKFC=Makefile
fi	# }

LSOF_LIB=lib
LSOF_MKF=Makefile
LSOF_LIBMKF=Makefile
LSOF_LIBMKFSKEL=Makefile.skel

LSOF_VF=version

# Make sure no other variable important to Makefile construction is
# already set in the environment.
#
#	$AFS_VICE	    locatiion of AFS VICE directory
#				(default = /usr/vice)
#	$LSOF_AFS	    AFS temporary
#	$LSOF_AFS_NQ	    AFS-not-qualified flag
#	$LSOF_AFSV	    AFS version
#	$LSOF_AR	    archive command and its arguments for making the
#			    lsof library
#	$LSOF_ARCH	    Unix dialect architecture as a string (may be
#			    supplied externally)
#	$LSOF_CC	    C compiler name (may be supplied externally)
#	$LSOF_CCV	    C compiler version (may be supplied externally)
#	$LSOF_CDIR	    configuration directory
#	$LSOF_CFGD	    depend options
#	$LSOF_CFGDN	    depend file name
#	$LSOF_CFGF	    C flags -- e.g., -D's
#	$LSOF_CFGL	    last lsof library loader flags -- e.g., -l's
#	$LSOF_CINFO	    Configure information for LSOF_CINFO in version.h
#	$LSOF_CTFH	    Solaris 10 and above libctf.h status
#	$LSOF_CTFL	    Solaris 10 and above -lctf status
#	$LSOF_DEBUG	    Makefile's DEBUG string
#	$LSOF_DINC	    include flags -- -I's
#	$LSOF_DINC_ADD	    include flags status
#	$LSOF_DOC	    special document (man page) directory path
#	$LSOF_ERR	    internal error flag
#	$LSOF_FCFGL	    first lsof library loader flags -- e.g., -l's
#			    that must precede $LSOF_LIB
#	$LSOF_FBSD_ZFS      FreeBSD $LSOF_FBSD_ZFS_MKF status
#	$LSOF_FBSD_ZFS_CFGF FreeBSD ZFS configure flags
#	$LSOF_FBSD_ZFS_MKF  FreeBSD ZFS Makefile name
#	$LSOF_FBSD_ZFS_SYS  FreeBSD ZFS system sources location
#	$LSOF_HOST	    host name (e.g., from uname -n)
#	$LSOF_INCLUDE	    directory where header files are found
#			    (default = /usr/include)
#	$LSOF_LD	    loader name if not $LSOF_CC
#	$LSOF_LIB_NO	    if "N" don't configure the lsof library
#	$LSOF_LOCALSUFFIX   local suffix for Makefile
#	$LSOF_NBSD_BUFQH    NetBSD <sys/bufq.h> copy status
#	$LSOF_NBSD_PTYFS    NetBSD ${NETBSD_SYS}/sys/fs/ptyfs/ copy status
#	$LSOF_N_UNIXV	    *BSD system's kernel file
#	$LSOF_OPINC	    supplies additional -I/path arguments for the
#			    Makefile's CFLAGS.
#	$LSOF_PL	    patch level
#	$LSOF_RANLIB	    randomizing command for the lsof library
#	$LSOF_RANLIB_SUP    if non-NULL $LSOF_RANLIB was supplied
#	$LSOF_SCRIPT_CALL   Customize and Inventory scripts call status
#	$LSOF_SPMKF	    Special Makefile name
#	$LSOF_TGT	    canonical target abbreviation (shortest)
#	$LSOF_TMP	    internal temporary
#	$LSOF_TMP1	    internal temporary
#	$LSOF_TMP2	    internal temporary
#	$LSOF_TMP3	    internal temporary
#	$LSOF_TMP4	    internal temporary
#	$LSOF_TMP5	    internal temporary
#	$LSOF_TMP6	    internal temporary
#	$LSOF_TMPC_BASE	    base name for $LSOF_TMPC
#	$LSOF_TMPC	    temporary C source file base name
#	$LSOF_TSTBIGF	    big file capability (for $LSOF_TSTCFLG)
#	$LSOF_TSTCC	    tests CC file
#	$LSOF_TSTCFLG	    tests CFLAGS file
#	$LSOF_TSTDFLG	    dialect-specific values for $LSOF_TSTCFLG
#	$LSOF_TSTK64	    status of 64 bit kernel (for $LSOF_TSTCFLG)
#	$LSOF_TSTKMEM	    /dev/kmem usage status (for $LSOF_TSTCFLG)
#	$LSOF_TSTLFF	    tests LDFLAGS file
#	$LSOF_TSTLFLG	    tests LDFLAGS values
#	$LSOF_TSTSUBD	    test subdirectory
#	$LSOF_TSTVPATH	    test v_path state (for $LSOF_TSTCFLG)
#	$LSOF_TSTXO	    test extra objects (for $LSOF_TSTXOC)
#	$LSOF_TSTXOC	    test extra objects file
#	$LSOF_UNSUP	    Lsof is unsupported on this dialect
#	$LSOF_UNSUP2	    Second message about lack of support
#	$LSOF_VERS	    Unix dialect version as a decimal number (may
#			    be supplied externally)
#	$LSOF_VSTR	    Unix dialect version as a string -- may be supplied
#			    externally

if test "X$AFS_VICE" = "X"	# {
then
  AFS_VICE="/usr/vice"
fi	# }
LSOF_AFS=""
LSOF_AFS_NQ=""
LSOF_AFSV=""
if test "X$LSOF_ARCH" = "X"	# {
then
  LSOF_ARCH=""
fi	# }
LSOF_CDIR=""
LSOF_CFGD=""
LSOF_CFGDN=""
LSOF_CINFO=""
LSOF_CTFH=0
LSOF_CTFL=0
LSOF_DEBUG=""
LSOF_DOC=""
LSOF_ERR=""
LSOF_FCFGL=""
LSOF_FBSD_ZFS=0
LSOF_FBSD_ZFS_CFGF=""
LSOF_FBSD_ZFS_MKF="Makefile.zfs"
LSOF_FBSD_ZFS_SYS=""
LSOF_HOST=""
if test "X$LSOF_INCLUDE" = "X"	# {
then
  LSOF_DINC=""
  LSOF_INCLUDE="/usr/include"
else
  LSOF_DINC="-I$LSOF_INCLUDE"
fi	# }
LSOF_LD=""
LSOF_LIB_NO=""
LSOF_PL=""
if test "X$LSOF_RANLIB" = "X"	# {
then
  LSOF_RANLIB="ranlib"
  LSOF_RANLIB_SUP=""
else
  LSOF_RANLIB_SUP="Y"
fi	# }
LSOF_SCRIPT_CALL="yes"
LSOF_SPMKF=""
LSOF_TMP1=""
LSOF_TMP2=""
LSOF_TMPC_BASE=./lsof_Configure_tmp_
LSOF_TMPC=${LSOF_TMPC_BASE}$$
LSOF_TSTBIGF=""
LSOF_TSTSUBD="./tests"
LSOF_TSTCC="${LSOF_TSTSUBD}/config.cc"
LSOF_TSTCFLG="${LSOF_TSTSUBD}/config.cflags"
LSOF_TSTDFLG=""
LSOF_TSTK64=0
LSOF_TSTKMEM=1
LSOF_TSTLFF="${LSOF_TSTSUBD}/config.ldflags"
LSOF_TSTLFLG=""
LSOF_TSTVPATH=0
LSOF_TSTXO=""
LSOF_TSTXOC="${LSOF_TSTSUBD}/config.xobj"
LSOF_UNSUP="WARNING: unsupported dialect or version"
LSOF_UNSUP2=""
if test "X$LSOF_VERS" = "X"	# {
then
  LSOF_VERS=""
fi	# }
if test "X$LSOF_VSTR" = "X"	# {
then
  LSOF_VSTR=""
fi	# }

# Establish echo type -- Berkeley or SYSV.

j=`echo -n ""`
if test "X$j" = "X-n "
then
  EC="\c"
  EO=""
else
  EC=""
  EO="-n"
fi

# Make sure temporary files are removed before an abnormal exit.

trap 'rm -f ${LSOF_HLP_BASE}* ${LSOF_TMPC_BASE}*; exit 1' 1 2 3 15

rm -f $LSOF_HLP
cat > $LSOF_HLP << LSOF_HLP
Usage: Configure <options> <target-dialect>
  <options>:  -clean        : clean up previous configuration
              -d|-dialects  : display a list of supported dialect versions
              -h|-help      : display help information
              -n            : avoid AFS, customization, and inventory checks
  <target-dialect> (****USE -d TO GET TESTED DIALECT VERSION NUMBERS****):
    aix|aixgcc              : IBM AIX xlc (aix) or gcc (aixgcc)
    darwin                  : Apple Darwin
    freebsd                 : FreeBSD
    hpux|hpuxgcc            : HP-UX cc (hpux) or gcc (hpuxgcc)
    linux                   : Linux
    netbsd                  : NetBSD
    openbsd                 : OpenBSD
    osr|sco                 : SCO OpenServer < 6.0.0, SCO developer's compiler
    osrgcc|scogcc           : SCO OpenServer < 6.0.0, gcc compiler
    osr6                    : SCO OpenServer 6.0.0, SCO compiler
    solaris|solariscc       : Solaris gcc (solaris) or cc (solariscc)
    unixware|uw             : SCO|Caldera UnixWare
LSOF_HLP

LSOF_TGT="no-target"

args=$#
while test $args -gt 0	# {
do
  case $1 in	# {
    -clean)
      if test -r $LSOF_MKFC	# {
      then
	echo "$LSOF_MAKE -f $LSOF_MKFC clean"
	$LSOF_MAKE -f $LSOF_MKFC clean
      else
	if test -r ${LSOF_LIB}/${LSOF_LIBMKF}	# {
	then
	  echo "(cd ${LSOF_LIB}; $LSOF_MAKE -f ${LSOF_LIBMKF} clean)"
	  (cd ${LSOF_LIB}; $LSOF_MAKE -f ${LSOF_LIBMKF} clean)
	else
	  if test -r ${LSOF_LIB}/${LSOF_LIBMKF}.skel	# {
	  then
	    echo "(cd ${LSOF_LIB}; $LSOF_MAKE -f ${LSOF_LIBMKF}.skel clean)"
	    (cd ${LSOF_LIB}; $LSOF_MAKE -f ${LSOF_LIBMKF}.skel clean)
	  fi	# }
	fi	# }
      fi	# }
      if test -r ${LSOF_TSTSUBD}/Makefile	# {
      then
	echo "(cd ${LSOF_TSTSUBD}; $LSOF_MAKE spotless)"
	(cd ${LSOF_TSTSUBD}; $LSOF_MAKE spotless)
      else
	echo '(cd ${LSOF_TSTSUBD}; rm *.o config.*)'
	(cd ${LSOF_TSTSUBD}; rm *.o config.*)
      fi	# }
      rm -f $LSOF_F $LSOF_MKFC $LSOF_FBSD_ZFS_MKF ${LSOF_TMPC_BASE}*
      echo rm -f $LSOF_F $LSOF_MKFC $LSOF_FBSD_ZFS_MKF ${LSOF_TMPC_BASE}*
      rm -rf AFSHeaders AFSVersion solaris11 version.h vnode_if.h
      echo "rm -rf AFSHeaders AFSVersion solaris11 version.h vnode_if.h"
      rm -f ${LSOF_HLP_BASE}* cd9660_node.h lockf_owner.h fbsd_minor.h
      echo "rm -f ${LSOF_HLP_BASE}* cd9660_node.h lockf_owner.h fbsd_minor.h"
      rm -f opt_kdtrace.h opt_random.h
      echo "rm -f opt_kdtrace.h opt_random.h"
      rm -f lib/dialects/aix/aix5/j2/j2_snapshot.h
      echo "rm -f lib/dialects/aix/aix5/j2/j2_snapshot.h"
      rm -f dialects/sun/solaris10	# DEBUG -- for s10_44
      echo "rm -f dialects/sun/solaris10"	# DEBUG -- for s10_44
      rm -f dialects/hpux/kmem/hpux_mount.h
      echo "rm -f dialects/hpux/kmem/hpux_mount.h"
      rm -rf lib/dialects/netbsd/include
      echo "rm -rf lib/dialects/netbsd/include"
      rm -f dialects/uw/uw7/vm/swap.h
      echo "rm -f dialects/uw/uw7/vm/swap.h"
      rm -f ${LSOF_LIB}/${LSOF_LIBMKF}
      echo "rm -f ${LSOF_LIB}/${LSOF_LIBMKF}"
      exit 0
      ;;

    -d|-dialects)
      if test -r ./00DIALECTS -a -r ./version	# {
      then
	V=`sed '/VN/s/.ds VN \(.*\)/\1/' version`
	echo "lsof $V has been *tested* on these UNIX dialect versions:"
	cat 00DIALECTS
	echo Although "$V hasn't been tested on other versions of these dialects,"
	echo "it may work.  Try \`Configure <dialect>\` and \`make\` to see."
	rm -f $LSOF_HLP
	exit 0
      else
	echo "Can't display UNIX dialect version information:"
	if test ! -r ./00DIALECTS	# {
	then
	  echo "	./00DIALECTS is inaccessible."
	fi	# }
	if test ! -r ./version	# {
	then
	  echo "	./version is inaccessible."
	fi	# }
	rm -f $LSOF_HLP
	exit 1
      fi	# }
      ;;

    -h|-help) cat $LSOF_HLP
      rm -f $LSOF_HLP
      exit 0
      ;;

    -n*)
      LSOF_SCRIPT_CALL="no"
      ;;

    *)
      if test "X$LSOF_TGT" != "Xno-target"	# {
      then
	echo "Only one dialect may be configured at a time."
	echo 'Both "$LSOF_TGT" and "$1" were specified.'
	cat $LSOF_HLP
	rm -f $LSOF_HLP
	exit 1
      else
	LSOF_TGT=$1
      fi	# }
      ;;
  esac	# }
  shift
  args=`expr $args - 1`
done	# }

case $LSOF_TGT in	# {
 no-target)
   echo "No target dialect was specified."
   cat $LSOF_HLP
   rm -f $LSOF_HLP
   exit 1
   ;;

# Configure for AIX xlc and AIX gcc.

  aix|aixgcc)

  # AIXA stands for AIX architecture.  It is assigned these values in this
  # stanza:
  #
  #    0	The AIX version is < 5.0, or the AIX 5.0 architecture is
  #		Power and the kernel bit size is 32.
  #
  #    1	The AIX version is >= 5.0, the AIX architecture is Power,
  #		and the kernel bit size is 64.
  #
  #    2	The AIX version is >= 5.0 and the architecture is IA64.

    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB="@echo \\\\\\\\c"    # AIX make doesn't like a null ${RANLIB}.
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then

      # If the AIX version isn't pre-defined, determine it.

      LSOF_TMP1=`uname -v`
      if test "X$LSOF_TMP1" = "X5"	# {
      then

	# If the AIX version is 5, build the version string with `uname -rv`
	# output.

	  LSOF_VSTR=`uname -r | awk '{printf "5.%d.0.0\n",\$1}'`
	  echo "Uname reports the version is $LSOF_VSTR."
      else

	# See if oslevel can determine the version.

	LSOF_TMP1=/usr/bin/oslevel
	if test -x $LSOF_TMP1	# {
	then
	  echo "Determining AIX version with $LSOF_TMP1."
	  echo "This may take a while, depending on your maintenance level."
	  LSOF_VSTR=`$LSOF_TMP1 | sed 's/[^0-9]*\([0-9\.]*\).*/\1/'`
	  echo "$LSOF_TMP1 reports the version is $LSOF_VSTR."
	else

	  # If oslevel can't be used, build the version string with
	  # `uname -rv` and issue a warning.

	  LSOF_VSTR=`uname -rv | awk '{printf "%d.%d.0.0\n",\$2,\$1}'`
	  echo "WARNING: can't execute $LSOF_TMP1; uname -rv reports"
	  echo "         the version is $LSOF_VSTR; edit CFGF in Makefile and"
	  echo "         lib/Makefile to refine AIXV and LSOF_VSTR."
	fi	# }
      fi	# }
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then
      LSOF_VERS=`echo $LSOF_VSTR | sed 's/\.//g'`
    fi	# }
    if test $LSOF_VERS -ge 4320	# {
    then
      LSOF_TSTBIGF=" "
    fi	# }
    if test "X$LSOF_CC" = "X"	# {
    then
      if test "X$LSOF_TGT" = "Xaixgcc"	# {
      then
	LSOF_CC=gcc
	LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
      else
	LSOF_CC=cc
      fi	# }
    fi	# }
    LSOF_TGT="aix"
    echo $LSOF_CC | grep gcc > /dev/null
    if test $? -eq 0	# {
    then

    # Prevent use of gcc for AIX below 4.1.

      if test $LSOF_VERS -lt 4100	# {
      then
	echo "********************************************************"
	echo "* Sorry, but gcc can't be used to compile lsof for AIX *"
	echo "* versions less than 4.1, because of possible kernel   *"
	echo "* structure alignment differences between it and xlc.  *"
	echo "********************************************************"
	rm -f $LSOF_HLP
	exit 1
      fi	# }
    fi	# }

    # Test for AFS.

    if test "X$AIX_HAS_AFS" != "X"	# {
    then
      LSOF_AFS=$AIX_HAS_AFS
    fi	# }
    if test "X$LSOF_AFS" != "Xno"	# {
    then
      if test "X$LSOF_AFS" = "Xyes" -o -r ${AFS_VICE}/etc/ThisCell	# {
      then
	if test "X$LSOF_AFS" != "Xyes"	# {
	then
	  if test "X$LSOF_SCRIPT_CALL" = "Xno"	# {
	  then
	    if test -r ./AFSHeaders -a -r ./AFSVersion	# {
	    then
	      LSOF_AFS="yes"
	    fi	# }
	  else
	    if test ! -x ./AFSConfig	# {
	    then
	      echo "Can't find or execute the AFSConfig script"
	      rm -f $LSOF_HLP
	      exit 1
	    fi	# }
	    ./AFSConfig
	    if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion	# {
	    then
	      LSOF_AFS="yes"
	    fi	# }
	  fi	# }
	fi	# }
	if test "X$LSOF_AFS" = "Xyes"	# {
	then
	  if test "X$LSOF_AFSV" = "X"	# {
	  then
	    if test -r ./AFSVersion	# {
	    then
	      LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'`
	    else
	      echo "!!!FATAL: no ./AFSVersion file.  It should have been"
	      echo "          created by a previous AFS configuration run."
	      rm -f $LSOF_HLP
	      exit 1
	    fi	# }
	  fi	# }
	  if test $LSOF_VERS -gt 4330 -o LSOF_AFSV -gt 305	# {
	  then
	    echo "!!!FATAL: Lsof does not support AFS on this combination of"
	    echo "          AIX ($LSOF_VERS) and AFS ($LSOF_AFSV) versions."
	    echo "          To disable AFS, set the value of the AIX_HAS_AFS"
	    echo "          environment variable to \"no\"."
	    rm -f $LSOF_HLP
	    exit 1
	  else
	    LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV"
	    LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`"
	    if test -r ${LSOF_INCLUDE}/sys/inttypes.h  # {
	    then
	      grep "^typedef.*int16;" ${LSOF_INCLUDE}/sys/inttypes.h > /dev/null
	      if test $? -eq 0      # {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHASINT16TYPE"
	      fi    # }
	      grep "^typedef.*u_int32;" ${LSOF_INCLUDE}/sys/inttypes.h > /dev/null
	      if test $? -eq 0      # {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHASUINT16TYPE"
	      fi    # }
	      grep "^typedef.*int32;" ${LSOF_INCLUDE}/sys/inttypes.h > /dev/null
	      if test $? -eq 0      # {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHASINT32TYPE"
	      fi    # }
	    fi	# }
	  fi      # }
	fi	# }
      fi	# }
    fi	# }

    # Miscellaneous AIX tests

    if test -d ${LSOF_INCLUDE}/nfs	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_NFS"
    fi	# }
    echo $LSOF_CC | grep cc | grep -v gcc > /dev/null
    if test $? -eq 0 -a $LSOF_VERS -ge 4140 -a $LSOF_VERS -lt 5000	# {
    then
      LSOF_CFGL="$LSOF_CFGL -bnolibpath"
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/socket.h	# {
    then
      grep AF_INET6 ${LSOF_INCLUDE}/sys/socket.h > /dev/null
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/stat.h	# {
    then
      grep stat64 ${LSOF_INCLUDE}/sys/stat.h > /dev/null
      if test $? -eq 0 # {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASSTAT64"
      fi	# }
    fi	# }
#DEBUG SANFS    if test -r ${LSOF_INCLUDE}/sys/sanfs/sanfsnode.h???	# {
#DEBUG SANFS    then
#DEBUG SANFS      LSOF_CFGF="$LSOF_CFGF -DHAS_SANFS"
#DEBUG SANFS    fi	# }
    if test $LSOF_VERS -ge 5000	# {
    then

    # This is AIX 5 or greater.

      if test -d ${LSOF_INCLUDE}/j2	# {
      then

      # The AIX > 5.0 system has jfs2 support.  Make the necesssary definitions
      # and adjustments.

	rm -f lib/dialects/aix/aix5/j2/j2_snapshot.h
	(cd lib/dialects/aix/aix5/j2; ln -s private_j2_snapshot.h j2_snapshot.h)
	LSOF_CFGF="$LSOF_CFGF -DHAS_JFS2"
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/lib/dialects/aix/aix5"
	if test $LSOF_VERS -ge 5200	# {
	then
	  if test -r ${LSOF_INCLUDE}/j2/j2_snapshot.h	# {
	  then

	  # The system has its own j2_snapshot.h, so make sure the
	  # private lsof copy is discarded.

	    rm -f lib/dialects/aix/aix5/j2/j2_snapshot.h
	  fi	# }
	  echo $LSOF_CC | grep gcc > /dev/null
	  if test $? -eq 0	# {
	  then

	  # Test gcc version for AIX 5.2.

	    LSOF_TMP1=`echo $LSOF_CCV | awk -F . '{printf "%d%02d",$1,$2}'`
	    if test $LSOF_TMP1 -ge 303	# {
	    then

	    # Add gcc >= 3.3 option to handle use of i_dev from the wInode
	    # anonymous structure reference in the JFS2 inode structure of
	    # <j2/j2_inode.h>.

	      LSOF_CFGF="$LSOF_CFGF -fms-extensions"
	    fi	# }
	  fi	#}
	fi	# }
      fi	# }

      # Determine the AIX architecture type and set AIXA accordingly.

      if test "X$AIX_ARCH" = "X"	# {
      then
	uname -a | grep -i ia64 > /dev/null
	if test $? -eq 0	# {
	then
	  AIX_ARCH="ia64"
	else
	  AIX_ARCH=""
	fi	# }
      fi	# }
      if test "X$AIX_ARCH" = "Xia64"	# {
      then

      # This is AIX >= 5 on ia64.

	LSOF_TSTK64=1
	echo $LSOF_CC | grep gcc > /dev/null
	if test $? -eq 0	# {
	then

	# Quit if gcc was specified as the compiler, since the gcc options to
	# do an ia64 lsof compilation are unknown.

	  echo "*************************************************************"
	  echo "*                                                           *"
	  echo "* !!!!!!!!!!!!!!!!!!!!! FATAL ERROR !!!!!!!!!!!!!!!!!!!!!!! *"
	  echo "*                                                           *"
	  echo "* Gcc can't be used to compile lsof for AIX 5 and above on  *"
	  echo "* the ia64 architecture.  Consult lsof's FAQ (in the file   *"
	  echo "* 00FAQ) for more information.                              *"
	  echo "*                                                           *"
	  echo "*************************************************************"
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
	LSOF_TMP1=2
	if test "X$LSOF_AR" = "X"	# {
	then
	  LSOF_AR="/usr/bin/ar cr"
	fi	# }
	LSOF_CFGF="$LSOF_CFGF -q64"
	LSOF_CFGL="$LSOF_CFGL -lelf"
      else

      # This is AIX >= 5 on Power architecture.

	echo $LSOF_CC | grep cc | grep -v gcc > /dev/null
	if test $? -eq 0	# {
	then
	  LSOF_CFGL="$LSOF_CFGL -bnolibpath"
	fi	# }
	if test "X$AIX_KERNBITS" = "X"	# {
	then

	# The kernel bit size wasn't predefined.  Determine it by compiling
	# and executing a test program.

	  rm -f ${LSOF_TMPC}.*
	  echo "#include <sys/systemcfg.h>" > ${LSOF_TMPC}.c
	  echo 'int main(){ if (__KERNEL_32()) printf("32\\n");' >> ${LSOF_TMPC}.c
	  echo 'else if (__KERNEL_64()) printf("64\\n");' >> ${LSOF_TMPC}.c
	  echo 'else printf("0\\n");' >> ${LSOF_TMPC}.c
	  echo "return(0); }" >> ${LSOF_TMPC}.c
	  echo "Testing kernel bit size with $LSOF_CC"
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x
	  if test ! -x ${LSOF_TMPC}.x	# {
	  then
	    echo "!!!FATAL: can't compile test program, ${LSOF_TMPC}.c."
	    rm -f $LSOF_HLP rm -f ${LSOF_TMPC}.*
	    exit 1
	  fi	# }
	  AIX_KERNBITS=`./${LSOF_TMPC}.x`
	  rm -f ${LSOF_TMPC}.*
	fi	# }

      # Use the kernel bit size specification to select archiver and compiler
      # options, and to update AIXA.

	case $AIX_KERNBITS in	# {
	32)
	  if test "X$LSOF_AR" = "X"	# {
	  then
	    LSOF_AR="/usr/bin/ar cr"
	  fi	# }
	  LSOF_TMP1=0
	  ;;
	64)
	  if test "X$LSOF_AR" = "X"	# {
	  then
	    LSOF_AR="/usr/bin/ar -X 64 -v -q"
	  fi	# }
	  LSOF_TSTK64=1
	  LSOF_TMP1=1
	  echo $LSOF_CC | grep gcc > /dev/null
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -maix64"
	  else
	    LSOF_CFGF="$LSOF_CFGF -q64"
	  fi	# }
	  ;;
	*)
	  echo "!!!FATAL: unrecognized kernel bit size: $AIX_KERNBITS"
	  rm -f $LSOF_HLP
	  exit 1
	esac	# }

      # Put kernel bit size information in $LSOF_CINFO and $LSOF_CFGF.

	echo "Kernel bit size: $AIX_KERNBITS"
	LSOF_TMP2="${AIX_KERNBITS} bit kernel"
	if test "X$LSOF_CINFO" != "X"	# {
	then
	  LSOF_CINFO="${LSOF_CINFO}  ${LSOF_TMP2}"
	else
	  LSOF_CINFO="${LSOF_TMP2}"
	fi	# }
	LSOF_CFGF="$LSOF_CFGF -DAIX_KERNBITS=${AIX_KERNBITS}"
      fi	# }
      LSOF_CFGF="$LSOF_CFGF -DAIXA=$LSOF_TMP1"
      if test "X$LSOF_TSTDFLG" = "X"	# {
      then
	LSOF_TSTDFLG="-DLT_AIXA=$LSOF_TMP1"
      else
	LSOF_TSTDFLG="$LSOF_TSTDFLG -DLT_AIXA=$LSOF_TMP1"
      fi	# }
    else

    # AIX is < 5, so set AIXA accordingly.

      LSOF_CFGF="$LSOF_CFGF -DAIXA=0"
      if test "X$LSOF_TSTDFLG" = "X"	# {
      then
	LSOF_TSTDFLG="-DLT_AIXA=0"
      else
	LSOF_TSTDFLG="$LSOF_TSTDFLG -DLT_AIXA=0"
      fi	# }
    fi	#}
    LSOF_CFGF="$LSOF_CFGF -DAIXV=$LSOF_VERS"
    LSOF_DIALECT_DIR=aix
    echo $LSOF_CC | grep gcc > /dev/null
    if test $? -eq 0 	# {
    then

    # Do gcc tests.

      if test $LSOF_VERS -ge 4100 -a $LSOF_VERS -lt 4200	# {
      then
	if test "X$AIX_USHACK" = "X"	# {
	then

	  # Compile and run a gcc test program to evaluate the user structure.

	  rm -f ${LSOF_TMPC}.*
	  echo "#include <stddef.h>" > ${LSOF_TMPC}.c
	  echo "#include <sys/user.h>" >> ${LSOF_TMPC}.c
	  echo "int main(){exit((offsetof(struct user, U_irss) & 0x7) ? 1 : 0);}" >>${LSOF_TMPC}.c
	  echo "Testing user.h with $LSOF_CC"
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x
	  if ! ${LSOF_TMPC}.x	# {
	  then
	    LSOF_TMP1=1
	  else
	    LSOF_TMP1=0
	  fi	# }
	  rm -f ${LSOF_TMPC}.*
	else
	  if test "$AIX_USHACK" = "Y" -o "$AIX_USHACK" = "y"	# {
	  then
	    LSOF_TMP1=1
	  else
	    LSOF_TMP1=0
	  fi	# }
	fi	# }
	if test ${LSOF_TMP1} -eq 1	# {
	then
	  echo "Applying gcc AIX 4.1+ user struct alignment hack"
	  rm -rf ./dialects/aix/aix$LSOF_VERS
	  mkdir ./dialects/aix/aix$LSOF_VERS
	  mkdir ./dialects/aix/aix${LSOF_VERS}/sys
	    sed 's/U_irss\[/dummy_for_alignment, U_irss\[/' < ${LSOF_INCLUDE}/sys/user.h > ./dialects/aix/aix${LSOF_VERS}/sys/user.h
	    LSOF_CFGF="$LSOF_CFGF -U_LONG_LONG -I`pwd`/dialects/aix/aix$LSOF_VERS"
	fi	# }
      fi	# }
    else

      # Get xlc version number

      rm -f ${LSOF_TMPC}.*
      echo "int main(){}" > ${LSOF_TMPC}.c
      echo "Getting version number of ${LSOF_CC}."
      $LSOF_CC -c ${LSOF_TMPC}.c -I${LSOF_INCLUDE} -o ${LSOF_TMPC}.o -qlist > /dev/null 2>&1
      LSOF_CCV=`head -1 ${LSOF_TMPC}.lst | sed 's/\(.*\) ---.*/\1/'`
      rm ${LSOF_TMPC}.*
      echo "The version is \"${LSOF_CCV}\"."
      echo $LSOF_CCV | grep "Version [0-9]" > /dev/null
      if test $? -eq 0	# {
      then
	LSOF_TMP=`echo $LSOF_CCV | sed 's/.*Version \([0-9]*\).*/\1/'`
	if test "X$LSOF_TMP" != "X" -a $LSOF_TMP -ge 4    # {
	then
	  if test $LSOF_TMP -ge 6	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -qmaxmem=-1"
	  else
	    LSOF_CFGF="$LSOF_CFGF -qmaxmem=16384"
	  fi	# }
	fi	# }
      fi	# }
    fi	# }
    if test $LSOF_VERS -ge 5300	# {
    then
      LSOF_UNSUP=""
    fi	# }
    ;;

# Configure for Apple Darwin.

  darwin)
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

    # If the Darwin / Mac OS X version isn't pre-defined, determine it.

      case $LSOF_VSTR in	# {
      1.2*)
	LSOF_VERS=120
	;;
      1.3*)
	LSOF_VERS=130
	;;
      1.4*)
	LSOF_VERS=140
	;;
      5.[012]*)
	LSOF_VERS=500
	;;
      5.[3-9]*)
	LSOF_VERS=530
	;;
      6.*)
	LSOF_VERS=600
	;;
      7.*)			# Mac OS X 10.3 (Panther)
	LSOF_VERS=700
	;;
      8.*)			# Mac OS X 10.4 (Tiger)
	LSOF_VERS=800
	;;
      9.*)			# Mac OS X 10.5 (Leopard)
	LSOF_VERS=900
 	;;
      10.*)			# Mac OS X 10.6 (SnowLeopard)
 	LSOF_VERS=1000
 	;;
      11.*)			# Mac OS X 10.7 (Lion)
 	LSOF_VERS=1100
 	;;
      12.*)			# Mac OS X 10.8 (Mountain Lion)
 	LSOF_VERS=1200
 	;;
      13.*)			# Mac OS X 10.9 (Mavericks)
	LSOF_VERS=1300
	;;
      14.*)			# Mac OS X 10.10 (Yosemite)
	LSOF_VERS=1400
	;;
      15.*)			# Mac OS X 10.11 (El Capitan)
	LSOF_VERS=1500
	;;
      16.*)			# macOS 10.12 (Sierra)
	LSOF_VERS=1600
	;;
      17.*)			# macOS 10.13 (High Sierra)
	LSOF_VERS=1700
	;;
      18.*)			# macOS 10.14 (Mojave)
	LSOF_VERS=1800
	;;
      19.*)			# macOS 10.15 (Catalina)
	LSOF_VERS=1900
	;;
      *)
	echo Unknown Darwin release: `uname -r`
	echo Assuming Darwin 19.0
	LSOF_VERS=1900
	;;
      esac	# }
    fi	# }

    # Do Darwin version-specific stuff.

    case $LSOF_VERS in	# {
    120|130)
      LSOF_TMP1="hfs/hfs.h hfs/hfs_macos_defs.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h"
      ;;
    140|500)
      LSOF_TMP1="hfs/hfs.h hfs/hfs_macos_defs.h hfs/rangelist.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h"
      ;;
    530)
      LSOF_TMP1="hfs/hfs.h hfs/hfs_macos_defs.h hfs/rangelist.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h net/ndrv.h net/ndrv_var.h"
      ;;
    600)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1="hfs/hfs.h hfs/hfs_catalog.h hfs/hfs_cnode.h hfs/hfs_macos_defs.h hfs/rangelist.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h net/ndrv_var.h net/raw_cb.h netinet/ip_var.h netinet/tcp_var.h"
      ;;
    700)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1="hfs/hfs.h hfs/hfs_catalog.h hfs/hfs_cnode.h hfs/hfs_macos_defs.h hfs/rangelist.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h net/ndrv_var.h net/raw_cb.h netinet/ip_var.h netinet/tcp_var.h sys/eventvar.h"
      ;;
    800)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1="net/ndrv_var.h net/raw_cb.h netinet/ip_var.h netinet/tcp_var.h sys/eventvar.h sys/file_internal.h sys/mount_internal.h sys/proc_internal.h sys/vnode_internal.h"
      ;;
    900|1000|1100|1200)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1=""
      LSOF_UNSUP=""
      LSOF_TSTBIGF=" "			# enable LTbigf test
      if test $LSOF_VERS -eq 900	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DNEEDS_MACH_PORT_T"
      fi	# }
      ;;
    1300|1400|1500|1600|1700|1800|1900)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1=""
      LSOF_UNSUP=""
      LSOF_TSTBIGF=" "			# enable LTbigf test
      ;;
    *)
      echo "Unsupported Darwin version: $LSOF_VERS"
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    LSOF_TMP2=""
    LSOF_TMP3=""
    LSOF_TMP4=""
    LSOF_CFGF="$LSOF_CFGF -mdynamic-no-pic"
    LSOF_CFGL="$LSOF_CFGL -lcurses"

    # Test Darwin base.

    if test "X$DARWIN_BASE" = "X" -o "X$DARWIN_BASE" = "Xlibproc"	# {
    then
      LSOF_TMP5=""
      if test $LSOF_VERS -ge 800 -o "X$DARWIN_BASE" = "Xlibproc"	# {
      then
	if test -r ${LSOF_INCLUDE}/libproc.h	# {
	then
	    DARWIN_BASE="libproc"
	else
	  if test -r ${LSOF_INCLUDE}/../local/include/libproc.h	# {
	  then
	    DARWIN_BASE="libproc"
	    LSOF_TMP5="${LSOF_INCLUDE}/../local/include"
	  else
	    if test -r /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libproc.h	# {
	    then
	      DARWIN_BASE="libproc"
	      LSOF_TMP5="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"
            else
              echo "FATAL: can't find libproc.h"
              rm -f $LSOF_HLP
              exit 1
            fi
	  fi	# }
	fi	# }
      else

        # The default Darwin base is libproc

	DARWIN_BASE="libproc"
      fi	# }
    fi	# }

    if test "X$DARWIN_BASE" = "Xlibproc"	# {
    then

      # Configure for libproc-based Darwin lsof.

      echo "Configuring libproc-based Darwin lsof"
      LSOF_CINFO="libproc-based"
      LSOF_DIALECT_DIR=darwin
      if test $LSOF_VERS -lt 1000 	# {
      then
	LSOF_CFGL="$LSOF_CFGL -lproc"
      fi	# }
      LSOF_TSTKMEM=0
      if test "X$LSOF_TMP5" != "X"  # {
      then
	LSOF_DINC="$LSOF_DINC -I$LSOF_TMP5"
      fi  # }
      if test ! -r ${LSOF_INCLUDE}/sys/proc_info.h	# {
      then
	if test "X$LSOF_TMP5" = "X" -o ! -r ${LSOF_TMP5}/sys/proc_info.h # {
	then
	  echo "FATAL: can't find sys/proc_info.h"
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
      fi	# }

    # Add header file paths for libproc-based Darwin lsof.

      for i in $LSOF_TMP3 $LSOF_TMP4 $LSOF_INCLUDE	# {
      do
	if test -d $i -a "X$i" != "X/usr/include"	# {
	then
	  LSOF_DINC="$LSOF_DINC -I${i}"
	fi	# }
      done	# }

    # Do other libproc-based Darwin lsof setups.

      if test -r ${LSOF_INCLUDE}/utmpx.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASUTMPX"
      fi	# }
    fi	# }
    LSOF_CFGF="$LSOF_CFGF -DDARWINV=$LSOF_VERS"
    LSOF_CFLAGS_OVERRIDE=1
    ;;

# Configure for FreeBSD.

  freebsd)
    LSOF_FBSD_ZFS=0
    LSOF_TSTKMEM=0
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

    # If the FreeBSD version isn't pre-defined, determine it.

      case $LSOF_VSTR in	# {
      13*)
	LSOF_CFGL="$LSOF_CFGL -lutil"
	LSOF_TSTBIGF=" "
	LSOF_VERS=13000
	;;
      14*)
	LSOF_CFGL="$LSOF_CFGL -lutil"
	LSOF_TSTBIGF=" "
	LSOF_VERS=14000
	;;
      15*)
	LSOF_CFGL="$LSOF_CFGL -lutil"
	LSOF_TSTBIGF=" "
	LSOF_VERS=15000
	;;
      16*)
	LSOF_CFGL="$LSOF_CFGL -lutil"
	LSOF_TSTBIGF=" "
	LSOF_VERS=16000
	;;
      *)
	echo Unknown FreeBSD release: `uname -r`
	rm -f $LSOF_HLP
	exit 1
	;;
      esac	# }
    fi	# }

    # Clear LSOF_UNSUP message for supported versions of FreeBSD.

    case $LSOF_VERS in  # {
    12000|13000|14000)
      LSOF_UNSUP=""
      ;;
    esac	# }

    # Get system CFLAGS, if possible.

    LSOF_TMP1=`echo "all:\n.include <bsd.prog.mk>" | $LSOF_MAKE -f- -VCFLAGS`
    LSOF_TMP=1
    while test $LSOF_TMP -eq 1	# {
    do
      echo $LSOF_TMP1 | grep -q -e '-O'
      if test $? -eq 0	# {
      then
	if test "X$LSOF_DEBUG" = "X"
	  then	# {
	    LSOF_DEBUG=`echo $LSOF_TMP1 | sed 's/.*\(-O[^ $]*\).*/\1/'`
	 fi	# }
	LSOF_TMP1=`echo $LSOF_TMP1 | sed 's/\(.*\)-O[^ $]*\(.*\)/\1 \2/' | sed 's/^  *//g' | sed 's/  */ /g' | sed 's/  *$//'`
      else
	LSOF_TMP=0
      fi	# }
      LSOF_FBSD_ZFS_CFGF="$LSOF_CFGF $LSOF_TMP1"
    done	# }
    LSOF_CFGF="$LSOF_CFGF $LSOF_TMP1"
    echo $LSOF_CFGF | grep -q NEEDS_BOOL_TYPEDEF
    if test $? -ne 0
    then	# {
      LSOF_CFGF="$LSOF_CFGF -DNEEDS_BOOL_TYPEDEF"
      LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DNEEDS_BOOL_TYPEDEF"
    fi	# }

    # Determine path to FreeBSD sources.

    LSOF_DINC_ADD=0
    if test "X$FREEBSD_SYS" = "X"	# {
    then
      if test -d /usr/src/sys	# {
      then
	FREEBSD_SYS=/usr/src/sys
      else
	if test -d /sys	# {
	then
	  FREEBSD_SYS="/sys"
	else
	  echo "!!!WARNING!!!  No kernel sources in /usr/src/sys or /sys (set FREEBSD_SYS)"
	fi	# }
      fi	# }
    fi	# }

    # Test for thread (task) support.

    if test -r ${LSOF_INCLUDE}/sys/user.h	# {
    then
      grep -q ki_numthreads ${LSOF_INCLUDE}/sys/user.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASTASKS"
      fi	# }
    else
      echo "FATAL: can't find sys/user.h"
      rm -f $LSOF_HLP
      exit 1
    fi	# }

    # All supported FreeBSD releases have closefrom and dup2.
    LSOF_CFGF="$LSOF_CFGF -DHAS_DUP2"
    LSOF_CFGF="$LSOF_CFGF -DHAS_CLOSEFROM"

    # Do FreeBSD version-specific stuff.

    case $LSOF_VERS in	# {
    1000)
      LSOF_CFGF="$LSOF_CFGF"
      LSOF_CFGL="$LSOF_CFGL -lutil"
      LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/freebsd/include"
      if test "X$FREEBSD_KERNEL" = "X"	# {
      then
	LSOF_N_UNIXV="/386bsd"
      else
	LSOF_N_UNIXV=$FREEBSD_KERNEL
      fi	# }
      ;;
    2000|2005|2010)
      LSOF_CFGL="$LSOF_CFGL -lkvm"
      ;;
    2020)
      LSOF_CFGL="$LSOF_CFGL -lkvm"
      if test -r ${LSOF_INCLUDE}/vm/lock.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVMLOCKH"
      fi	# }
      ;;
    3000|3010|3020|3030|3040|3050)
      LSOF_CFGL="$LSOF_CFGL -lkvm"
      if test -r ${LSOF_INCLUDE}/nfs/rpcv2.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASRPCV2H"
      fi	# }
      if test -r ${LSOF_INCLUDE}/vm/lock.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVMLOCKH"
      fi	# }
      ;;
    *)
      if test -r ${LSOF_INCLUDE}/nfs/rpcv2.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASRPCV2H"
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/namei.h	# {
      then
	grep -q "^struct[ 	]*namecache[ 	]*{" ${LSOF_INCLUDE}/sys/namei.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASNAMECACHE"
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/ufs/ufs/inode.h	# {
      then
	grep -q i_effnlink ${LSOF_INCLUDE}/ufs/ufs/inode.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASEFFNLINK=i_effnlink"
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/file.h	# {
      then
	grep -q f_vnode ${LSOF_INCLUDE}/sys/file.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASF_VNODE"
	fi	# }
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lkvm"
      if test $LSOF_VERS -ge 5000	# {
      then

      # Do FreeBSD 5 and higher version-specific stuff.

	if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
	then
	  grep VT_FDESC ${LSOF_INCLUDE}/sys/vnode.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    if test ! -r ${LSOF_INCLUDE}/fs/devfs/devfs.h	# {
	    then
	      if test -r ${FREEBSD_SYS}/fs/devfs/devfs.h	# {
	      then
		LSOF_DINC_ADD=1
	      else
		echo "!!!FATAL: lsof cannot locate the devfs.h header file"
		echo "          in ${LSOF_INCLUDE}/fs/devfs/devfs.h or"
		echo "          ${FREEBSD_SYS}/fs/devfs/devfs.h.  Consult"
		echo "          00FAQ for an explanation."
		rm -f $LSOF_HLP
		exit 1
	      fi	# }
	    fi	# }
	  fi	# }
	fi	# }
	if test -r ${FREEBSD_SYS}/sys/filedesc.h	# {
	then
	  grep -q filedescent ${FREEBSD_SYS}/sys/filedesc.h
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_FILEDESCENT"
	  fi	# }
	fi	# }
	if test -r ${FREEBSD_SYS}/fs/tmpfs/tmpfs.h	# {
	then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_TMPFS"
	fi	#}

      # Do FreeBSD 5.2 and higher version-specific stuff.

	if test -r ${LSOF_INCLUDE}/wctype.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASWCTYPE_H"
	fi	# }
	if test $LSOF_VERS -ge 5020	# {
	then

	# Determine the status of the cpumask_t typedef.

	  rm -f ${LSOF_TMPC}.*
	  cat > ${LSOF_TMPC}.c << .LSOF_END_HERE_DOC3
#undef _KERNEL
#include <sys/types.h>
int main() {
cpumask_t c;
}
.LSOF_END_HERE_DOC3
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
	  LSOF_TMP1=$?
	  rm -f ${LSOF_TMPC}.*
	  if test $LSOF_TMP1 -ne 0	# {
	  then

	  # The cpumask_t typedef is unknown when _KERNEL is not defined.

	    if test -r ${LSOF_INCLUDE}/sys/types.h \
		    -a -r ${LSOF_INCLUDE}/machine/_types.h	# {
	    then
	      grep -q cpumask_t ${LSOF_INCLUDE}/sys/types.h
	      if test $? -eq 0	# {
	      then
	        grep -q __cpumask_t ${LSOF_INCLUDE}/machine/_types.h
	        if test $? -eq 0	# {
	        then
		  LSOF_CFGF="$LSOF_CFGF -DHASCPUMASK_T"
	        else
		  $LSOF_CC -E ${LSOF_INCLUDE}/machine/_types.h 2>/dev/null | grep -q __cpumask_t
		  if test $? -eq 0  # {
		  then
		    LSOF_CFGF="$LSOF_CFGF -DHASCPUMASK_T"
		  fi	# }
	        fi	# }
	      fi	# }
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/socketvar.h	# {
	  then
	    grep -q SBS_CANT ${LSOF_INCLUDE}/sys/socketvar.h
	    if test $? -eq 0	# {
	    then
		LSOF_CFGF="$LSOF_CFGF -DHASSBSTATE"
	    fi	# }
	  fi	# }
	fi	# }
	if test $LSOF_VERS -ge 5030	# {
	then

	# Do FreeBSD 5.3 and higher version-specific stuff.

	  if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
	  then
	    grep -q "defined(_KVM_VNODE)" ${LSOF_INCLUDE}/sys/vnode.h
	    if test $? -eq 0	# {
	    then
		LSOF_CFGF="$LSOF_CFGF -DHAS_KVM_VNODE"
	    fi	#}
	  fi	# }
	fi	# }
	if test $LSOF_VERS -ge 6000	# {
	then

	# Do FreeBSD 6.0 and higher version-specific stuff.

	  if test -r ${LSOF_INCLUDE}/sys/_types.h	# {
	  then
	    grep __dev_t ${LSOF_INCLUDE}/sys/_types.h | grep -q 64
	    if test $? -eq 0	# {
	    then
	      if test "X$LSOF_TSTDFLG" = "X"	# {
	      then
		LSOF_TSTDFLG="-DLT_DEV64"
	      else
		LSOF_TSTDFLG="$LSOF_TSTDFLG -DLT_DEV64"
	      fi	# }
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/ufs/ufs/inode.h	# {
	  then
	    grep -q i_din2 ${LSOF_INCLUDE}/ufs/ufs/inode.h
	    if test $? -eq 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_UFS1_2"
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/conf.h	# {
	  then
	    grep -q vm_memattr_t ${LSOF_INCLUDE}/sys/conf.h
	    if test $? -eq 0	#{
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_VM_MEMATTR_T"
	    fi	# }
	    grep -q device_t ${LSOF_INCLUDE}/sys/eventhandler.h
	    if test $? -eq 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DNEEDS_DEVICE_T"
	    fi	# }
	    grep -q "^#define	minor(" ${LSOF_INCLUDE}/sys/conf.h
	    if test $? -eq 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_CONF_MINOR"
	      rm -f fbsd_minor.h
	      if test -r ${LSOF_INCLUDE}/sys/types.h	# {
	      then
		LSOF_TMP1=`grep "^#define[ 	]minor(" ${LSOF_INCLUDE}/sys/types.h`
		if test "X$LSOF_TMP1" != "X"	# {
		then
		  echo "Creating fbsd_minor.h"
		  cat > fbsd_minor.h << FBSD_MINOR1
/*
 * fbsd_minor.h -- created by lsof Configure script on
FBSD_MINOR1
		  echo $EO " * $EC" >> ./fbsd_minor.h
		  date >> ./fbsd_minor.h
		  cat >> ./fbsd_minor.h << FBSD_MINOR2
 */

#if	!defined(FBSD_MINOR_H)
#define	FBSD_MINOR_H

FBSD_MINOR2
		  echo $EO "${LSOF_TMP1}${EC}" >> fbsd_minor.h
		  cat >> ./fbsd_minor.h << FBSD_MINOR3

#endif	/* defined(FBSD_MINOR_H) */
FBSD_MINOR3
		fi	# }
	      fi	# }
	    else
	      if test -r ${FREEBSD_SYS}/fs/devfs/devfs_int.h	# {
	      then
		grep -q cdev2priv ${FREEBSD_SYS}/fs/devfs/devfs_int.h
		if test $? -eq 0	# {
		then
		  LSOF_CFGF="$LSOF_CFGF -DHAS_CDEV2PRIV"
		fi	# }
	      fi	# }
	    fi	# }
	    grep -q si_priv ${LSOF_INCLUDE}/sys/conf.h
	    if test $? -eq 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_SI_PRIV"
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/sx.h	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_SYS_SX_H"
	  fi	# }

	# Do msdosfs test.
	  if test -r ${FREEBSD_SYS}/fs/msdosfs/denode.h # {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASMSDOSFS"
	  fi    # }
	# Do ZFS test.  Try for the newer OpenSolaris files first -- i.e.,
	# the ones in ${FREEBSD_SYS}/cddl/contrib/opensolaris.  If that fails,
	# try for the older ones in ${FREEBSD}/contrib/opensolaris.

	  LSOF_FBSD_ZFS_SYS=${FREEBSD_SYS}/cddl
	  if test ! -r ${LSOF_FBSD_ZFS_SYS}/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h	# {
	  then
	    LSOF_FBSD_ZFS_SYS=${FREEBSD_SYS}
	    if test ! -r ${LSOF_FBSD_ZFS_SYS}/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h	# {
	    then
	      LSOF_FBSD_ZFS_SYS=""
	    fi	# }
	  fi	# }
	  if test "X$LSOF_FBSD_ZFS_SYS" != "X"	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_ZFS"
	    LSOF_FBSD_ZFS=1
	    LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DFREEBSDV=$LSOF_VERS"
	    LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DHAS_ZFS"
	    grep -q z_phys ${LSOF_FBSD_ZFS_SYS}/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
	    if test $? -eq 0	# {
	    then
	      LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DHAS_Z_PHYS"
	    fi	# }
	    if test -r ${LSOF_FBSD_ZFS_SYS}/compat/opensolaris/sys/sdt.h  #{
	    then
	      grep -q opt_kdtrace.h ${LSOF_FBSD_ZFS_SYS}/compat/opensolaris/sys/sdt.h
	      if test $? -eq 0	# {
	      then
		rm -f opt_kdtrace.h
		touch opt_kdtrace.h
	      fi	# }
	    fi	# }
	    if test -r ${LSOF_FBSD_ZFS_SYS}/compat/opensolaris/sys/kcondvar.h #{
	    then
		grep -q cv_timedwait_sbt ${LSOF_FBSD_ZFS_SYS}/compat/opensolaris/sys/kcondvar.h
		if test $? -eq 0	# {
		then
		  LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DHAS_CV_TIMEDWAIT_SBT"
		fi	# }
	    fi	#}
	    if test -r /usr/include/sys/random.h	# {
	    then
	      grep -q opt_random.h /usr/include/sys/random.h
	      if test $? -eq 0	# {
	      then
		rm -f opt_random.h
		touch opt_random.h
	      fi	# }
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
	  then

	  # See if the vnode contains the byte level lock pointer.

	    grep -q v_lockf ${LSOF_INCLUDE}/sys/vnode.h
	    if test $? -eq 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_V_LOCKF"
	      if test $LSOF_FBSD_ZFS -eq 1	# {
	      then
	        LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DHAS_V_LOCKF"
	      fi	# }
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/lockf.h	# {
	  then

	  # Determine the type of locking structure to which the inode or
	  # vnode points.

	    grep -q "^struct lockf_entry" ${LSOF_INCLUDE}/sys/lockf.h
	    if test $? -eq 0	# {
	    then

	    # Build the ./lockf_owner.h header file.

	      LSOF_TMP1=""
	      LSOF_TMP2=0
	      echo "Creating ./lockf_owner.h from ${FREEBSD_SYS}/kern/kern_lockf.c"
	      rm -f ./lockf_owner.h
	      if test -r ${FREEBSD_SYS}/kern/kern_lockf.c	# {
	      then
		LSOF_TMP1=`grep -n "^struct lock_owner {" ${FREEBSD_SYS}/kern/kern_lockf.c | sed 's/\([0-9]*\):.*$/\1/'`
		if test "X$LSOF_TMP1" != "X"	# {
		then
		  LSOF_TMP2=0
		  for i in `grep -n "};" ${FREEBSD_SYS}/kern/kern_lockf.c | sed 's/\([0-9]*\):.*$/\1/'` # {
		  do
		    if test $LSOF_TMP2 -eq 0 -a $i -gt $LSOF_TMP1	# {
		    then
		      LSOF_TMP2=$i
		    fi	# }
		  done	# }
		  if test $LSOF_TMP2 -eq 0	# {
		  then
		    LSOF_TMP1=""
		  else
		    cat > ./lockf_owner.h << LOCKF_OWNER1
/*
 * lockf_owner.h -- created by lsof Configure script on
LOCKF_OWNER1
		    echo $EO " * $EC" >> ./lockf_owner.h
		    date >> ./lockf_owner.h
		    cat >> ./lockf_owner.h << LOCKF_OWNER2
 */

#if	!defined(LOCKF_OWNER_H)
#define	LOCKF_OWNER_H

LOCKF_OWNER2
		    ed -s ${FREEBSD_SYS}/kern/kern_lockf.c >> ./lockf_owner.h << LOCKF_OWNER3
${LSOF_TMP1},${LSOF_TMP2}p
LOCKF_OWNER3
		    if test $? -ne 0	# {
		    then
		      LSOF_TMP1=""
		    else
		      cat >> ./lockf_owner.h << LOCKF_OWNER4

#endif	/* defined(LOCKF_OWNER_H) */
LOCKF_OWNER4
		    fi	# }
		  fi	# }
		fi	# }
	      else
		echo "FATAL ERROR: can't read ${FREEBSD_SYS}/kern/kern_lockf.c"
	      fi	# }
	      if test "X$LSOF_TMP1" != "X" -a "X$LSOF_TMP2" != "X0" # {
	      then
		echo "./lockf_owner.h creation succeeded."
	        LSOF_CFGF="$LSOF_CFGF -DHAS_LOCKF_ENTRY"
	      else
		echo "FATAL ERROR: ./lockf_owner.h creation failed (see 00FAQ)"
		rm -f $LSOF_HLP
		exit 1
	      fi	# }
	    fi	# }

	  # Test for in6p_.port in inpcb structure.

	    if test -r ${LSOF_INCLUDE}/netinet/in_pcb.h	# {
	    then
	      grep -q 'in6p_.port' ${LSOF_INCLUDE}/netinet/in_pcb.h
	      if test $? -ne 0	# {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHAS_NO_6PORT"
	      fi	# }
	    fi	# }

	  # Test for in6p_ppcb in inpcb structure.

	    if test -r ${LSOF_INCLUDE}/netinet/in_pcb.h	# {
	    then
	      grep -q 'in6p_ppcb' ${LSOF_INCLUDE}/netinet/in_pcb.h
	      if test $? -ne 0	# {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHAS_NO_6PPCB"
	      fi	# }
	    fi	# }
	    if test -r ${LSOF_INCLUDE}/sys/conf.h	# {
	    then
	      grep -q 'doadump(boolean_t)' ${LSOF_INCLUDE}/sys/conf.h
	      if test $? -eq 0	# {
	      then
		LSOF_CFGF="$LSOF_CFGF -DNEEDS_BOOLEAN_T"
	      fi	# }
	    fi	# }
	    if test -r ${LSOF_INCLUDE}/sys/sockbuf.h	# {
	    then
	      grep -q 'u_int	sb_ccc;' ${LSOF_INCLUDE}/sys/sockbuf.h
	      if test $? -eq 0	# {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHAS_SB_CCC"
	      fi	# }
	    fi	# }
	  fi	# }
	fi	# }
      fi	# }
      if test $LSOF_VERS -eq 10000	# {
      then

      # Do specific FreeBSD 10 version-specific stuff.

	LSOF_TMP1=`uname -m`
	if test "X$LSOF_TMP1" = "Xi386"	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DNEEDS_BOOL_TYPEDEF"
	fi	# }
      fi	# }
      ;;
    esac	# }
    LSOF_CFGF="$LSOF_CFGF -DFREEBSDV=$LSOF_VERS"
    if test $LSOF_VERS -lt 2000 -a "X$FREEBSD_KERNEL" = "X"	# {
    then
      if test ! -x $LSOF_N_UNIXV	# {
      then
	echo "Hmmm -- $LSOF_N_UNIXV doesn't appear to be your kernel file."
	echo "Please enter the name of the file in / that contains"
	echo "the kernel for this host.  It must be a regular file,"
	echo "not a directory, and must be executable."
	LSOF_LOOP=1
	while test $LSOF_LOOP = 1	# {
	do
	  echo ""
	  echo "/ contains:"
	  echo ""
	  ls -CF /
	  echo ""
	  echo -n "Kernel file name? "
	  read LSOF_N_UNIXV LSOF_EXCESS
	  LSOF_N_UNIXV="/$LSOF_N_UNIXV"
	  if test ! -d $LSOF_N_UNIXV -a -x $LSOF_N_UNIXV	# {
	  then
	    LSOF_LOOP=0
	  else
	    echo ""
	    echo $LSOF_N_UNIXV is not a regular executable file.
	  fi	# }
	done	# }
      fi	# }
      LSOF_N_UNIXV=`echo $LSOF_N_UNIXV | sed 's#^/*#/#'`
      LSOF_CFGF="$LSOF_CFGF -DN_UNIXV=$LSOF_N_UNIXV"
    fi	# }
    if test -r ${FREEBSD_SYS}/miscfs/fdesc/fdesc.h	# {
    then
      LSOF_TMP1=${FREEBSD_SYS}/miscfs/fdesc/fdesc.h
    else
      if test $LSOF_VERS -ge 5000 -a -r ${LSOF_INCLUDE}/fs/fdescfs/fdesc.h  # {
      then
	LSOF_TMP1=${LSOF_INCLUDE}/fs/fdescfs/fdesc.h
      else
	LSOF_TMP1=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP1" != "X"	# {
    then
      grep -q Fctty $LSOF_TMP1
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=1"
      else
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=2"
      fi	# }
      grep -q fd_link $LSOF_TMP1
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDLINK"
      fi	# }
      LSOF_DINC_ADD=1
    fi	# }
    if test $LSOF_VERS -ge 5000	# {
    then
      LSOF_TMP1="fs"
    else
      LSOF_TMP1="miscfs"
    fi	# }
    LSOF_CFGF="$LSOF_CFGF -DHASPROCFS"
    if test -d ${FREEBSD_SYS}/${LSOF_TMP1}/pseudofs	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASPSEUDOFS"
      LSOF_DINC_ADD=1
    fi	# }
    if test -r ${LSOF_INCLUDE}/${LSOF_TMP1}/nullfs/null.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASNULLFS"
    else
      if test -r ${FREEBSD_SYS}/${LSOF_TMP1}/nullfs/null.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNULLFS"
	LSOF_DINC_ADD=1
      fi	# }
    fi	# }
    if test -r ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h	# {
    then
      ISOFS_DIR="${FREEBSD_SYS}/isofs/cd9660"
    else
      if test -r ${FREEBSD_SYS}/fs/cd9660/cd9660_node.h		# {
      then
        ISOFS_DIR="${FREEBSD_SYS}/fs/cd9660"
      fi	# }
    fi	# }
    if test "X$ISOFS_DIR" != "X"				# {
    then
      rm -f cd9660_node.h
      grep -q "^#ifdef [_]*KERNEL" ${ISOFS_DIR}/cd9660_node.h
      if test $? -eq 0	# {
      then
	ln -s ${ISOFS_DIR}/cd9660_node.h cd9660_node.h
      else
	sed -e '/^ \* Prototypes for ISOFS vnode operations/,$c\
	\ The ISOFS prototypes were removed by Configure. */' \
	< ${ISOFS_DIR}/cd9660_node.h > cd9660_node.h
	echo "" >> cd9660_node.h
      fi	# }
      LSOF_CFGF="$LSOF_CFGF -DHAS9660FS"
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/namei.h
    then
      grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNCVPID"
      fi	# }
    fi	# }
    if test $LSOF_DINC_ADD -eq 1	# {
    then
      if test "X$LSOF_DINC" = "X"	# {
      then
	LSOF_DINC="-I${FREEBSD_SYS}"
      else
	LSOF_DINC="$LSOF_DINC -I${LSOF_INCLUDE} -I${FREEBSD_SYS}"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/netinet/in.h	# {
    then
      grep IPV6_INRIA_VERSION ${LSOF_INCLUDE}/netinet/in.h > /dev/null
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASIPv6 -DHASINRIAIPv6"
      fi	# }
    fi	# }
    echo $CFGF | grep HASIPv6 > /dev/null
    if test $? -ne 0 -a -r ${LSOF_INCLUDE}/netinet6/in6.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
    fi	# }
    if test -r ${LSOF_INCLUDE}/utmpx.h # {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASUTMPX"
    fi	# }

    # Does struct xtcpcb have t_maxseg?
    rm -f ${LSOF_TMPC}.*
    cat > ${LSOF_TMPC}.c << .LSOF_END_HERE_DOC4
#undef _KERNEL
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socketvar.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp_var.h>
int main() {
struct xtcpcb pcb; pcb.t_maxseg = 0;
}
.LSOF_END_HERE_DOC4
    $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
    if test $? -eq 0	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_XTCPCB_TMAXSEG"
    fi	# }
    rm -f ${LSOF_TMPC}.*

    # Does struct kinfo_file have kf_un.kf_sock.kf_sock_sendq?
    grep -q kf_sock_sendq ${LSOF_INCLUDE}/sys/user.h
    if test $? -eq 0	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_KF_SOCK_SENDQ"
    fi	# }

    # Does struct kinfo_file have kf_un.kf_file.kf_file_nlink?
    grep -q kf_file_nlink ${LSOF_INCLUDE}/sys/user.h
    if test $? -eq 0	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_KF_FILE_NLINK"
    fi	# }

    LSOF_DIALECT_DIR=freebsd
    ;;

# Configure for HP-UX and HP-UX gcc.

  hpux|hpuxgcc)
    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB=""
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the HP-UX version isn't pre-defined, determine it.

      LSOF_VERS=`echo $LSOF_VSTR | awk -F. '{printf "%d%02d",\$2,\$3}'`
    fi	# }
    if test $LSOF_VERS -ge 1020	# {
    then
      LSOF_TSTBIGF="-D_LARGEFILE64_SOURCE"
    fi	# }

    # Determine compiler.

    if test "X$LSOF_CC" = "X"	# {
    then
      if test "X$LSOF_TGT" = "Xhpuxgcc"	# {
      then
	LSOF_CC=gcc
      else
	if test "X$HPUX_CCDIR1" = "X"	# {
	then
	  HPUX_CCDIR1="/bin"
	fi	# }
	if test "X$HPUX_CCDIR2" = "X"	# {
	then
	  HPUX_CCDIR2="/usr/ccs/bin"
	fi	# }
	if test -x ${HPUX_CCDIR1}/cc	# {
	then
	  LSOF_CC=${HPUX_CCDIR1}/cc
	else
	  if test -x ${HPUX_CCDIR2}/cc	# {
	  then
	    LSOF_CC=${HPUX_CCDIR2}/cc
	  else
	    echo "No executable cc in $HPUX_CCDIR1 or $HPUX_CCDIR2"
	    rm -f $LSOF_HLP
	    exit 1
	  fi	# }
	fi	# }
	$LSOF_CC -O < /dev/null 2>&1 | grep -q Bundled
	if test $? -eq 0	# {
	then
	  LSOF_DEBUG="No-O"			# to disable -O
	  if test "X$HPUX_LIBC1" = "X"	# {
	  then
	    HPUX_LIBC1="/usr/lib"
	  fi	# }
	  if test -r ${HPUX_LIBC1}/libc.sl	# {
	  then
	    LSOF_FCFGL="-L$HPUX_LIBC -lc"
	  else
	    if test "X$HPUX_LIBC2" = "X"	# {
	    then
	      HPUX_LIBC2="/usr/lib"
	    fi	# }
	    if test -r ${HPUX_LIBC2}/libc.sl	# {
	    then
	      LSOF_FCFGL="-L$HPUX_LIBC2 -lc"
	    fi	# }
	  fi	# }
	fi	# }
      fi	# }
    fi	# }
    echo $LSOF_CC | grep gcc > /dev/null
    if test $? -eq 0	# {
    then
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    else
      $LSOF_CC -O < /dev/null 2>&1 | grep -q Bundled
      if test $? -eq 0	# {
      then
	LSOF_DEBUG="No-O"			# to disable -O
      fi	# }
    fi	# }
    LSOF_TGT=hpux

    # Test for "const void" support.

    rm -f ${LSOF_TMPC}.*
    echo "int main() { const void *x; return(0); }" >> $LSOF_TMPC.c
    $LSOF_CC $LSOF_TMPC.c -o $LSOF_TMPC.x > /dev/null 2>&1
    if test $? -eq 0	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_CONST"
    fi	# }
    rm -f ${LSOF_TMPC}.*

    # Test HP-UX base.

    if test "X$HPUX_BASE" = "X"	# {
    then
      if test -d $LSOF_INCLUDE/sys/pstat -a $LSOF_VERS -ge 1111 	# {
      then
	HPUX_BASE="pstat"
      else
	HPUX_BASE="/dev/kmem"
      fi	# }
    fi	# }
    if test "X$HPUX_BASE" = "Xpstat"	# {
    then

      # Configure for pstat-based HP-UX lsof.

      LSOF_CINFO="PSTAT-based"
      echo "Configuring PSTAT-based HP-UX lsof"
      LSOF_DIALECT_DIR=hpux/pstat
      LSOF_CFGF="$LSOF_CFGF -DHPUXV=$LSOF_VERS -D_PSTAT64"
      LSOF_CFGL="$LSOF_CFGL -lnsl"
      LSOF_TSTKMEM=0
      LSOF_TSTK64=1
      ls -l $LSOF_CC | grep -q ansic
      LSOF_TMP1=$?
      ls -l $LSOF_CC | grep -q aCC
      if test $? -eq 0 -o $LSOF_TMP1 -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -Ae +DD32"
      else
	echo $LSOF_CC | grep -q gcc
	if test $? -ne 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF +DD32"
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/netinet/in6.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/pstat/stream_pstat_body.h	# {
      then
	grep -q PS_STR_XPORT_DATA ${LSOF_INCLUDE}/sys/pstat/stream_pstat_body.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -D_PSTAT_STREAM_GET_XPORT"
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 1123	# {
      then
	LSOF_CFGF="$LSOF_CFGF -D_LARGEFILE64_SOURCE"
      fi	# }
    else
      if test "X$HPUX_BASE" = "X/dev/kmem"	# {
      then

	# Configure for /dev/kmem-based HP-UX lsof.

	if test "X$HPUX_BOOTFILE" = "X"	# {
	then
	  HPUX_BOOTFILE="/stand/vmunix"
	fi	# }
	if test $LSOF_VERS -gt 1100	# {
	then
	  echo ""
	  echo "************************************************"
	  echo "*                                              *"
	  echo "* !!!!!!!!!!!!!!! FATAL ERROR !!!!!!!!!!!!!!!! *"
	  echo "*                                              *"
	  echo "* LSOF DOES NOT SUPPORT THIS VERSION OF HP-UX. *"
	  echo "*                                              *"
	  echo "************************************************"
	  echo ""
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
	LSOF_CFGF="$LSOF_CFGF -DHPUXV=$LSOF_VERS"
	LSOF_CINFO="/dev/kmem-based"
	LSOF_DIALECT_DIR=hpux/kmem
	echo "Configuring /dev/kmem-based HP-UX lsof"
	if test $LSOF_VERS -lt 1000	# {
	then
	  if test "X$HPUX_X25DIR" = "X"	# {
	  then
	    HPUX_X25DIR="/etc/conf"
	  else
	    HPUX_X25DIR=$HPUX_X25DIR
	  fi	# }
	  if test -r ${HPUX_X25DIR}/x25/x25addrstr.h	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHPUX_CCITT"
	    LSOF_DINC="$LSOF_DINC -I$HPUX_X25DIR"
	  fi	# }
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h -a -r ${LSOF_INCLUDE}/sys/fs/vx_hpux.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS"
	fi	# }
	if test $LSOF_VERS -ge 1030	# {
	then
	  if test "X$HPUX_KERNBITS" = "X"	# {
	  then
	    HPUX_KERNBITS=`getconf _SC_KERNEL_BITS`
	  fi	# }
	  LSOF_CFGF="$LSOF_CFGF -DHPUXKERNBITS=${HPUX_KERNBITS} -I`pwd`/dialects/hpux/kmem/hpux11"
	  if test $HPUX_KERNBITS -eq 64	# {
	  then
	    LSOF_TSTK64=1
	    echo ""
	    echo "*****************************************"
	    echo "*                                       *"
	    echo "* NOTICE!  Configuring for 64 bit HP-UX *"
	    echo "*                                       *"
	    echo "*****************************************"
	    echo $LSOF_CC | grep gcc > /dev/null
	    if test $? -eq 0	# {
	    then

	    # Test gcc for 64 bit support, trying gcc with no options, then
	    # with -mlp64, testing the result with file.

	      echo ""
	      echo "Testing $LSOF_CC for 64 bit support"
	      rm -f ${LSOF_TMPC}.*
	      echo "int main(){}" > ${LSOF_TMPC}.c
	      LSOF_TMP1=""
	      $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
	      if test $? -eq 0	# {
	      then
		/bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null
		if test $? -eq 0	# {
		then
		    LSOF_TMP1=" "
		fi	# }
	      fi	# }
	      if test "X$LSOF_TMP1" = "X"	# {
	      then
		rm -f ${LSOF_TMPC}.x
		$LSOF_CC ${LSOF_TMPC}.c -mlp64 -o ${LSOF_TMPC}.x > /dev/null 2>&1
		if test $? -eq 0	# {
		then
		  /bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null
		  if test $? -eq 0	# {
		  then
		      LSOF_TMP1="-mlp64"
		  fi	# }
		fi	# }
	      fi	# }
	      rm -f ${LSOF_TMPC}.*
	      if test "X$LSOF_TMP1" = "X"	# {
	      then
		echo ""
		echo "***************************************************"
		echo "*                                                 *"
		echo "* !!!!!!!!!!!!!!!!! FATAL ERROR !!!!!!!!!!!!!!!!! *"
		echo "*                                                 *"
		echo "* APPARENTLY GCC CANNOT BUILD 64 BIT EXECUTABLES. *"
		echo "* A COMPILER MUST BE USED THAT CAN.  SEE 00FAQ    *"
		echo "* FOR MORE INFORMATION.                           *"
		echo "*                                                 *"
		echo "***************************************************"
		echo ""
		rm -f $LSOF_HLP
		exit 1
	      else
		if test "X$LSOF_TMP1" != "X "	# {
		then
		  LSOF_CFGF="$LSOF_CFGF $LSOF_TMP1"
		fi	# }
		LSOF_CFGL="$LSOF_CFGL -lelf"
		LSOF_CINFO="${LSOF_CINFO}, 64 bit HP-UX"
	      fi	# }
	    else

	    # Set options for the HP-UX compiler.

	      LSOF_CFGF="$LSOF_CFGF +DD64"
	      LSOF_CFGL="$LSOF_CFGL -lelf"
	      LSOF_CINFO="${LSOF_CINFO}, 64 bit HP-UX"
	    fi	# }
	  else
	    LSOF_CFGF="$LSOF_CFGF -D_FILE_OFFSET_BITS=64"
	    LSOF_CINFO="${LSOF_CINFO}, 32 bit HP-UX"
	    echo $LSOF_CC | grep gcc > /dev/null
	    if test $? -ne 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF +DAportable"
	    fi	# }
	  fi	# }
	  LSOF_CFGL="$LSOF_CFGL -lnsl"
	else

	# When HP-UX is less than 10.30, but greater than or equal to 10,
	# check NFS3 rnode status.

	  if test $LSOF_VERS -ge 1000	# {
	  then
	    LSOF_TMP1=0
	    if test "X$HPUX_RNODE3" = "X"	# {
	    then
	      nm -x $HPUX_BOOTFILE | grep -q nfs_vnodeops3
	      if test $? -eq 0	# {
	      then
		if test -r ${LSOF_INCLUDE}/nfs/rnode.h	# {
		then
		  grep -q r_fh3 ${LSOF_INCLUDE}/nfs/rnode.h
		  if test $? -ne 0	# {
		  then
		    LSOF_TMP1=1
		  fi	# }
		fi	# }
	      fi	# }
	    else
	      if test "X$HPUX_RNODE3" = "X1"	# {
	      then
		LSOF_TMP1=1
	      fi	# }
	    fi	# }
	    if test $LSOF_TMP1 -eq 1	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHASRNODE3"
	    fi	# }
	  fi # }
	fi	# }
	if test $LSOF_VERS -eq 1100	# {
	then

	# Test for the ipis_s structure.  If it is present, set HAS_IPC_S_PATCH.

	  if test "X$HPUX_IPC_S_PATCH" = "X"	# {
	  then
	    if test -x /usr/contrib/Q4/bin/q4exe	# {
	    then
	      LSOF_TMP=/usr/contrib/Q4/bin/q4exe
	    else
	      LSOF_TMP=/usr/contrib/bin/q4
	    fi	# }
	    if test -x $LSOF_TMP	# {
	    then
	      rm -f ${LSOF_TMPC}.out
	      echo ""
	      echo $EO "Looking in $HPUX_BOOTFILE for ipis_s with $LSOF_TMP ... $EC"
	      echo "yes\\nfields -c struct ipis_s" | $LSOF_TMP $HPUX_BOOTFILE > ${LSOF_TMPC}.out 2>&1
	      if test $? -ne 0	# {
	      then
		echo ""
		echo ""
		echo "!!!ERROR!!! $LSOF_TMP failed and produced the following output."
		echo ""
		cat ${LSOF_TMPC}.out
		HPUX_IPC_S_PATCH=fail
	      else
		grep ipis_s ${LSOF_TMPC}.out > /dev/null 2>&1
		if test $? -eq 0	# {
		then
		  echo "ipis_s exists."

		# See if ipis_msgsqueued is present.

		  grep ipis_msgsqueued ${LSOF_TMPC}.out > /dev/null 2>&1
		  if test $? -eq 0	# {
		  then
		    HPUX_IPC_S_PATCH=2
		  else
		    HPUX_IPC_S_PATCH=1
		  fi	# }
		else
		  echo "ipis_s doesn't exist."
		  HPUX_IPC_S_PATCH=N
		fi	# }
	      fi	# }
	      rm -f ${LSOF_TMPC}.out
	    else
	      echo "Can't locate or execute $LSOF_TMP"
	      echo $EO "ls says: $EC"
	      ls -ld $LSOF_TMP
	      HPUX_IPC_S_PATCH=fail
	    fi	# }
	  fi	# }
	  if test "X$HPUX_IPC_S_PATCH" = "Xfail"	# {
	  then
	    echo ""
	    echo "!!!ERROR!!!     !!!ERROR!!!     !!!ERROR!!!     !!!ERROR!!!"
	    echo "Configure can't use $LSOF_TMP to examine the ipis_s"
	    echo "structure.  You must do that yourself, report the result in"
	    echo "the HPUX_IPC_S_PATCH environment variable, then repeat the"
	    echo "Configure step.  Consult the Configure script's use of"
	    echo "$LSOF_TMP and the 00XCONFIG file for information"
	    echo "on ipis_s testing and the setting of HPUX_IPC_S_PATCH."
	    echo "!!!ERROR!!!     !!!ERROR!!!     !!!ERROR!!!     !!!ERROR!!!"
	    echo ""
	    rm -f $LSOF_HLP
	    exit 1
	  fi	# }
	  if test "X$HPUX_IPC_S_PATCH" = "X1" -o "X$HPUX_IPC_S_PATCH" = "X2" # {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_IPC_S_PATCH=$HPUX_IPC_S_PATCH"
	  else
	    if test "X$HPUX_IPC_S_PATCH" != "Xn" -a "X$HPUX_IPC_S_PATCH" != "XN" # {
	    then
	      echo "Illegal value for HPUX_IPC_S_PATCH: $HPUX_IPC_S_PATCH"
	      rm -f $LSOF_HLP
	      exit 1
	    fi	# }
	  fi	# }
	fi	#}

	# Manufacture an hpux_mount.h header file with a mount struct in it, as
	# required.

	if test -r ${LSOF_INCLUDE}/sys/mount.h	# {
	then
	  LSOF_TMP1="dialects/${LSOF_DIALECT_DIR}/hpux_mount.h"
	  rm -f $LSOF_TMP1
	  echo "#if !defined(MANUFACTURED_HPUX_SYS_MOUNT_H)" > $LSOF_TMP1
	  echo "#define MANUFACTURED_HPUX_SYS_MOUNT_H" >> $LSOF_TMP1
	  echo "/* By lsof Configure:" `date` " */" >> $LSOF_TMP1
	  echo "struct mount" >> $LSOF_TMP1
	  sed '1,/struct mount/d' ${LSOF_INCLUDE}/sys/mount.h | sed -n '1,/m_dev/p' >> $LSOF_TMP1
	  echo "};" >> $LSOF_TMP1
	  echo "#endif" >> $LSOF_TMP1
	  LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/${LSOF_DIALECT_DIR}"
	fi	# }

	# Test for OnlineJFS.

	if test $LSOF_VERS -ge 1100	# {
	then
	  if test "X$HPUX_HASONLINEJFS" = "X" -a -x /sbin/fs/vxfs/subtype  # {
	  then
	    LSOF_TMP1=`/sbin/fs/vxfs/subtype`
	    if test "X$LSOF_TMP1" = "Xvxfs3.3"
	    then
	      HPUX_HASONLINEJFS="Y"
	    fi	# }
	  fi	# }
	  if test "X$HPUX_HASONLINEJFS" = "XY" -o "X$HPUX_HASONLINEJFS" = "Xy"
	  # {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASONLINEJFS"
	  fi	# }
	fi	# }

	# Test for AFS.

	if test -r ${AFS_VICE}/etc/ThisCell	# {
	then
	  if test "X$LSOF_SCRIPT_CALL" = "Xno"	# {
	  then
	    if test -r ./AFSHeaders -a -r ./AFSVersion	# {
	    then
	      LSOF_AFS="yes"
	    fi	# }
	  else
	    if test ! -x ./AFSConfig	# {
	    then
	      echo "Can't find or execute the AFSConfig script"
	      rm -f $LSOF_HLP
	      exit 1
	    fi	# }
	    ./AFSConfig
	    if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion	# {
	    then
	      LSOF_AFS="yes"
	    fi	# }
	  fi	# }
	  if test "X$LSOF_AFS" = "Xyes"	# {
	  then
	    LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'`
	    LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV"
	    LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`"
	  fi	# }
	fi	# }
      else
	echo "HP-UX base unrecognized: $HPUX_BASE"
	rm -f $LSOF_HLP
	exit 1
      fi	# }
    fi	# }
    ;;

# Configure for Linux.

  linux)
    LSOF_TSTBIGF="-D_FILE_OFFSET_BITS=64"
    LSOF_TSTKMEM=0
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LINUX_CONF_CC" = "X"	# {
    then
      LINUX_CONF_CC=$LSOF_CC
    fi	#}
    LSOF_DIALECT_DIR=""
    if test "X$LINUX_INCL" = "X" # {
    then
      LINUX_INCL=/usr/include
    else
      LSOF_DINC="$LSOF_DINC -I${LINUX_INCL}"
    fi	# }
    if test "X$LINUX_VERSION_CODE" = "X" # {
    then
      if test -r "$LINUX_INCL/linux/version.h" # {
      then
        LINUX_VERSION_CODE=`cat $LINUX_INCL/linux/version.h | sed -n 's/.\+LINUX_VERSION_CODE \([[:digit:]]\+\)$/\1/p'`
      fi # }
    fi # }
    LSOF_VSTR=`echo $LINUX_VERSION_CODE | perl -e '$version=<STDIN>; chomp($version); printf("%d.%d.%d\n", ($version >> 16) & 0xFF, ($version >> 8) & 0xFF, $version & 0xFF);'`
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the Linux version isn't predefined, determine it.

      LSOF_VERS=`echo $LSOF_VSTR | sed 's/\./ /g' | awk '{printf "%d%d%03d",\$1,\$2,\$3}'`
    fi	# }
    LSOF_CFGF="$LSOF_CFGF -DLINUXV=$LSOF_VERS"
    if test $LSOF_VERS -lt 21072	# {
    then
      echo ""
	echo "!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!"
	echo "!                                                        !"
	echo "! THE /PROC-BASED LSOF SOURCES HAVE NOT BEEN TESTED ON   !"
	echo "! LINUX KERNELS BELOW 2.1.72, AND MAY NOT WORK ON THIS   !"
	echo "! KERNEL.  IT SHOULD USE A /DEV/KMEM-BASED LSOF.         !"
	echo "!                                                        !"
	echo "!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!"
	echo ""
    else
      LSOF_UNSUP=""
    fi	# }

    # If the Linux C library type isn't predefined, determine it.

    if test "X$LINUX_CLIB" = "X"	# {
    then
      echo -n "Testing C library type with $LINUX_CONF_CC ... "
      rm -f ${LSOF_TMPC}.*
      cat > $LSOF_TMPC.c << .LSOF_END_HERE_DOC1
#include <features.h>
#include <stdio.h>
int main() {
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
printf("-DGLIBCV=%d\n",__GLIBC__*100+__GLIBC_MINOR__);
#elif defined(__GLIBC__)
printf("-DGLIBCV=%d00\n",__GLIBC__);
#else
printf("\n");
#endif
return(0); }
.LSOF_END_HERE_DOC1
      $LINUX_CONF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1
      if test -x ${LSOF_TMPC}.x	# {
      then
	LINUX_CLIB=`${LSOF_TMPC}.x`
	LSOF_TMP=$?
      else
	LINUX_CLIB=""
	LSOF_TMP=1
      fi	# }
      rm -f ${LSOF_TMPC}.*
      echo "done"
      if test $LSOF_TMP -ne 0	# {
      then
	echo "Cannot determine C library type; assuming it is not glibc."
	LINUX_CLIB=""
      else
	if test "X$LINUX_CLIB" = "X"	# {
	then
	  echo "The C library type is not glibc."
	else
	  echo "The C library type is glibc, version \"$LINUX_CLIB\"."
	fi	# }
      fi	# }
    fi	# }
    if test "X$LINUX_CLIB" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF $LINUX_CLIB"
    fi	# }

    # Test for IPv6 support.

    if test -r ${LSOF_INCLUDE}/netinet/ip6.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
    fi	# }

    # Test for <rpc/rpc.h>.

    if test -r ${LSOF_INCLUDE}/rpc/rpc.h	# {
    then
      :	# Do nothing
    elif test -r ${LSOF_INCLUDE}/tirpc/rpc/rpc.h
    then
      LSOF_DINC="${LSOF_DINC} -I${LSOF_INCLUDE}/tirpc"
      LSOF_CFGL="${LSOF_CFGL} -ltirpc"
    else
      LSOF_CFGF="$LSOF_CFGF -DHASNORPC_H"
    fi	# }

    # Test for TCP_* symbols.

    if test -r ${LSOF_INCLUDE}/netinet/tcp.h	# (
    then
      grep -q TCP_ESTABLISHED ${LSOF_INCLUDE}/netinet/tcp.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DNEEDS_NETINET_TCPH"
      fi	#}
    fi	# }

    # Test for SELinux support.

    LSOF_TMP1=0
    if test "X$LINUX_HASSELINUX" = "X"	# {
    then
      if test -r ${LSOF_INCLUDE}/selinux/selinux.h	# {
      then
	LSOF_TMP1=1
      fi	# }
    else
      if test "X$LINUX_HASSELINUX" = "XY" -o "X$LINUX_HASSELINUX" = "Xy" # {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    if test $LSOF_TMP1 -eq 1	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASSELINUX"
      LSOF_CFGL="$LSOF_CFGL -lselinux"
    fi	# }

  # Test for UNIX socket endpoint support.

    if test -r ${LSOF_INCLUDE}/linux/sock_diag.h -a -r ${LSOF_INCLUDE}/linux/unix_diag.h  # {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASUXSOCKEPT"
    fi	# }

  # Test for pseudoterminal endpoint support.

    if test -r ${LSOF_INCLUDE}/linux/major.h # {
    then
      grep -q TTYAUX_MAJOR ${LSOF_INCLUDE}/linux/major.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASPTYEPT"
      fi	# }
    fi	# }

  # Test for (unix) socket state support.

    if test -f ${LSOF_INCLUDE}/linux/net.h # {
    then
      grep -q SS_CONNECTED ${LSOF_INCLUDE}/linux/net.h
      if test $? -eq 0 # {
      then
        LSOF_CFGF="$LSOF_CFGF -DHASSOSTATE -DHASSOOPT"
      fi	# }
    fi	# }

  # Test for dup2 and closefrom

    if test -f ${LSOF_INCLUDE}/unistd.h # {
    then
      grep -q dup2 ${LSOF_INCLUDE}/unistd.h
      if test $? -eq 0 # {
      then
        LSOF_CFGF="$LSOF_CFGF -DHAS_DUP2"
      fi	# }

      grep -q closefrom ${LSOF_INCLUDE}/unistd.h
      if test $? -eq 0 # {
      then
        LSOF_CFGF="$LSOF_CFGF -DHAS_CLOSEFROM"
      fi	# }
    fi	# }

    LSOF_DIALECT_DIR="linux"
    LSOF_CFGF="$LSOF_CFGF -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE"
    ;;

# Configure for NetBSD.

  netbsd)
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # Validate the NetBSD version.

      case $LSOF_VSTR in	# {
      1.2*)
	LSOF_VERS="1002000"
	;;
      1.3*)
	LSOF_VERS="1003000"
	;;
      1.4*)
	LSOF_VERS="1004000"
	;;
      1.5*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="1005000"
	;;
      1.6*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="1006000"
	;;
      1.*)
	LSOF_VERS="1006000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 1.6"
	;;
      2.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="2000000"
	;;
      2.99.9)
	LSOF_TSTBIGF=" "
	LSOF_VERS="2099009"
	;;
      2.99.10)
	LSOF_TSTBIGF=" "
	LSOF_VERS="2099010"
	;;
      2.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="2099010"
	;;
      2.*)
	LSOF_VERS="2000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 2.0"
	;;
      3.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="3000000"
	;;
      3.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="3099000"
	;;
      3.*)
	LSOF_VERS="3000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 3.0"
	;;
      4.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="4000000"
	;;
      4.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="4099000"
	;;
      4.*)
	LSOF_VERS="4000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 4.0"
	;;
      5.[012]*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="5000000"
	;;
      5.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="5099000"
	;;
      5.*)
	LSOF_VERS="5000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 5.0"
	;;
      6.[01]*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="6000000"
	;;
      6.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="6099000"
	;;
      6.*)
	LSOF_VERS="6000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 6.0"
	;;
      7.[01]*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="7000000"
	;;
      7.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="7099000"
	;;
      7.*)
	LSOF_VERS="7000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 7.0"
	;;
      8.[0123]*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="8000000"
	;;
      8.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="8099000"
	;;
      8.*)
	LSOF_VERS="8000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 8.0"
	;;
      9.[0123]*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="9000000"
	;;
      9.99.10[45678])
	LSOF_TSTBIGF=" "
	LSOF_VERS="9099104"
	;;
      9.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="9099000"
	;;
      9.*)
	LSOF_VERS="9000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 9.0"
	;;
      10.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="10099000"
	;;
      10.*)
	LSOF_VERS="10000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 10.0"
	;;
      *)
	echo "Unknown NetBSD release: $LSOF_VSTR"
	echo Assuming NetBSD 10.0
	LSOF_VERS="10000000"
	;;
      esac	# }
    fi	# }

    LSOF_CFGF="$LSOF_CFGF -DNETBSDV=$LSOF_VERS"

    # For paddr_t
    LSOF_CFGF="$LSOF_CFGF -D_KMEMUSER"
    # For struct namecache
    LSOF_CFGF="$LSOF_CFGF -D__NAMECACHE_PRIVATE"

    LSOF_TMP1="-DN_UNIXV=/netbsd"
    if test -r /dev/ksyms              # {
    then
      LSOF_TMP1="-DN_UNIXV=/dev/ksyms"
    elif test -r ${LSOF_INCLUDE}/util.h        # {
    then
      grep -q getbootfile ${LSOF_INCLUDE}/util.h
      if test $? -eq 0	# {
      then
	LSOF_CFGL="$LSOF_CFGL -lutil"
	LSOF_TMP1="-DHASGETBOOTFILE"
      fi	# }
    fi	# }
    LSOF_CFGF="$LSOF_CFGF $LSOF_TMP1"
    if test -r ${LSOF_INCLUDE}/kvm.h	# {
    then
      grep -q kvm_getproc2 ${LSOF_INCLUDE}/kvm.h
      if test $? -eq 0	# {
      then
	  LSOF_CFGF="$LSOF_CFGF -DHASKVMGETPROC2"
      fi	# }
    fi	# }

  # Here begin the dual tests on header files that may be in $LSOF_INCLUDE
  # or $NETBSD_SYS.
  #
  # Note that $LSOF_TMP1 holds an indicator of the need for -I$NETBSD_SYS.
  # LSOF_TMP4 contains a temporary indicator of the use of $NETBSD_SYS.

    LSOF_TMP1=0
    if test "X$NETBSD_SYS" = "X"	# {
    then
      if test -d /usr/src	# {
      then
	NETBSD_SYS="/usr/src/sys"
      else
	NETBSD_SYS=$LSOF_INCLUDE
      fi	# }
    fi	# }
    LSOF_TMP2="nfs/nfsproto.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASNFSPROTO"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    LSOF_TMP2="netinet/ip6.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    else
      LSOF_TMP2="netinet/in.h"
      if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
	LSOF_TMP4=0
      else
	if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
	then
	  LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	  LSOF_TMP4=1
	else
	  LSOF_TMP3=""
	fi	# }
      fi	# }
      if test "X$LSOF_TMP3" != "X"	# {
      then
	grep -q IPV6_INRIA_VERSION $LSOF_TMP3
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASIPv6 -DHASINRIAIPv6"
	  if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	  then
	    LSOF_TMP1=1
	  fi	# }
	fi	# }
      fi # }
    fi	# }
    LSOF_TMP2="miscfs/fdesc/fdesc.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q Fctty $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=1"
      else
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=2"
      fi	# }
      grep -q fd_link $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDLINK"
      fi	# }
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    LSOF_TMP2="miscfs/nullfs/null.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASNULLFS"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    LSOF_TMP2="miscfs/procfs"
    if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASPROCFS"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
      if test -r ${LSOF_TMP3}/procfs.h	# {
      then
	grep -q PFSroot ${LSOF_TMP3}/procfs.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPROCFS_PFSROOT"
	fi #	}
      fi	# }
    fi	# }
    LSOF_TMP2="sys/bufq.h"
    LSOF_NBSD_BUFQH=0
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASBUFQ_H"
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	if test $NETBSD_SYS != $LSOF_INCLUDE	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASBUFQ_H"
	  LSOF_NBSD_BUFQH=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="isofs/cd9660"
    if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS9660FS=1"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    else
      LSOF_TMP2="fs/cd9660"
      if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
	LSOF_TMP4=0
      else
	if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
	then
	  LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	  LSOF_TMP4=1
	else
	  LSOF_TMP3=""
	fi	# }
      fi	# }
      if test "X$LSOF_TMP3" != "X"	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS9660FS=1"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="msdosfs"
    if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASMSDOSFS=1"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    else
      LSOF_TMP2="fs/msdosfs"
      if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
	LSOF_TMP4=0
      else
	if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
	then
	  LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	  LSOF_TMP4=1
	else
	  LSOF_TMP3=""
	fi	# }
      fi	# }
      if test "X$LSOF_TMP3" != "X"	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASMSDOSFS=2"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="miscfs/kernfs/kernfs.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q "kt_name;" $LSOF_TMP3
      if test $? -eq 0	# {
	then
 	  LSOF_CFGF="$LSOF_CFGF -DHASKERNFS"
	  if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	  then
	    LSOF_TMP1=1
	  fi	# }
	  grep -q "*kfs_kt;" $LSOF_TMP3
	  if test $? -eq 0      # {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASKERNFS_KFS_KT"
	  fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/namei.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q nc_vpid $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNCVPID"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="ufs/ufs/inode.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q i_ffs_size $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASI_FFS"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      else
	grep -q i_ffs1_size $LSOF_TMP3
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASI_FFS1"
	  if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	  then
	    LSOF_TMP1=1
	  fi	# }
	fi	# }
      fi	# }
      grep -q i_ffs_effnlink $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASEFFNLINK=i_ffs_effnlink"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/vnode.h"
    LSOF_NBSD_PTYFS=0
    LSOF_NBSD_TMPFS=0
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "XLSOF_TMP3" != "X"	# {
    then
      grep -q VT_EXT2FS $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASEXT2FS"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
	LSOF_TMP2="ufs/ufs/inode.h"
	if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
	then
	  LSOF_TMP5="${LSOF_INCLUDE}/$LSOF_TMP2"
	  LSOF_TMP6=0
	else
	  if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
	  then
	    LSOF_TMP5="${NETBSD_SYS}/$LSOF_TMP2"
	    LSOF_TMP6=1
	  else
	    LSOF_TMP5=""
	  fi	# }
	fi	# }
	if test "X$LSOF_TMP5" != "X"	# {
	then
	  grep -q "*e2fs_din" $LSOF_TMP5
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASI_E2FS_PTR"
	    if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	    then
	      LSOF_TMP1=$LSOF_TMP6
	    fi	# }
	  fi	# }
	fi	# }
      fi	# }
      grep -q VT_LFS $LSOF_TMP3
      if test $? -eq 0   # {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASLFS"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
      grep -q VT_PTYFS $LSOF_TMP3
      if test $? -eq 0   # {
      then
	LSOF_TMP2="fs/ptyfs/ptyfs.h"
	if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPTYFS"
	else
	  if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
	  then
	    if test $NETBSD_SYS != $LSOF_INCLUDE	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHASPTYFS"
	      LSOF_NBSD_PTYFS=1
	    fi	# }
	  fi	# }
	fi	# }
      fi	# }
      grep -q VT_TMPFS $LSOF_TMP3
      if test $? -eq 0   # {
      then
       LSOF_TMP2="fs/tmpfs/tmpfs.h"
       if test -r ${LSOF_INCLUDE}/$LSOF_TMP2   # {
       then
         LSOF_CFGF="$LSOF_CFGF -DHASTMPFS"
       else
         if test -r ${NETBSD_SYS}/$LSOF_TMP2   # {
         then
           if test $NETBSD_SYS != $LSOF_INCLUDE        # {
           then
             LSOF_CFGF="$LSOF_CFGF -DHASTMPFS"
             LSOF_NBSD_TMPFS=1
           fi  # }
         fi    # }
       fi      # }
      fi       # }
      if test "X$NETBSD_UVM" = "X"	# {
      then
	if test -r ${LSOF_INCLUDE}/uvm	# {
	then
	  NETBSD_UVM="Y"
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="nfs/nfsnode.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q "*n_vattr" $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNFSVATTRP"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/lockf.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q vop_advlock_args $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_ADVLOCK_ARGS"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
      grep -q lf_lwp $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_LF_LWP"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/lwp.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_LWP_H"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    LSOF_TMP2="sys/filedesc.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q "^struct cwdinfo {" $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASCWDINFO"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/pipe.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_SYS_PIPEH"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/statvfs.h 	# {
    then
      grep -q '^struct statvfs {' ${LSOF_INCLUDE}/sys/statvfs.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASSTATVFS"
      fi	# }
    fi	# }

  # Here end the dual NetBSD tests for header files in $LSOF_INCLUDE or
  # NETBSD_SYS.
  #
  # After this LSOF_TMP1 may be reused.

    if test $LSOF_TMP1 -eq 1	# {
    then
      LSOF_DINC="-I$LSOF_INCLUDE -I$NETBSD_SYS"
    fi	# }

  # Build special header files, as required.

    rm -rf lib/dialects/netbsd/include
    if test "X$NETBSD_UVM" = "XY" -o "X$NETBSD_UVM" = "Xy"	# {
    then
      mkdir lib/dialects/netbsd/include
      touch lib/dialects/netbsd/include/opt_uvmhist.h
      touch lib/dialects/netbsd/include/opt_lockdebug.h
      LSOF_CFGF="$LSOF_CFGF -DUVM -I`pwd`/lib/dialects/netbsd/include"
      if test -d ${LSOF_INCLUDE}/uvm	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_UVM_INCL"
      fi	# }
    fi	# }
    LSOF_TMP2="sys/mount.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then

      # Build a local NetBSD netexport.h header file for possible use by
      # <msdosfs/msdosfsmount.h>.  Make sure CFGL contains a -I for it.

      LSOF_TMP1=${LSOF_TMPC}.edscr
      LSOF_TMP2=${LSOF_TMPC}.netcred
      LSOF_TMP3=${LSOF_TMPC}.netexport
      LSOF_TMP4=lib/dialects/netbsd/include/netexport.h
      if test ! -d lib/dialects/netbsd/include	# {
      then
	mkdir lib/dialects/netbsd/include
      fi	# }
      rm -f $LSOF_TMP1 $LSOF_TMP2 $LSOF_TMP3 $LSOF_TMP4
      echo "/^struct netcred" > $LSOF_TMP1
      echo "1,.-1d" >> $LSOF_TMP1
      echo "/^};" >> $LSOF_TMP1
      echo "1,.w $LSOF_TMP2" >> $LSOF_TMP1
      ed ${LSOF_INCLUDE}/sys/mount.h < $LSOF_TMP1 > /dev/null 2>&1
      rm -f $LSOF_TMP1
      echo "/^struct netexport" > $LSOF_TMP1
      echo "1,.-1d" >> $LSOF_TMP1
      echo "/^};" >> $LSOF_TMP1
      echo "1,.w $LSOF_TMP3" >> $LSOF_TMP1
      ed ${LSOF_INCLUDE}/sys/mount.h < $LSOF_TMP1 > /dev/null 2>&1
      echo "/*" > $LSOF_TMP4
      echo " * netexport.h" >> $LSOF_TMP4
      echo -n " * Created by Configure: " >> $LSOF_TMP4
      echo `date` >> $LSOF_TMP4
      echo " */" >> $LSOF_TMP4
      echo "" >> $LSOF_TMP4
      echo "#if	!defined(NETEXPORT_H)" >> $LSOF_TMP4
      echo "#define	NETEXPORT_H" >> $LSOF_TMP4
      echo "" >> $LSOF_TMP4
      echo "#include <net/radix.h>" >> $LSOF_TMP4
      echo "" >> $LSOF_TMP4
      if test -r $LSOF_TMP2	# {
      then
	cat $LSOF_TMP2 >> $LSOF_TMP4
	echo "" >> $LSOF_TMP4
      fi	# }
      if test -r $LSOF_TMP3	# {
      then
	cat $LSOF_TMP3 >> $LSOF_TMP4
      fi	# }
      echo "#endif	/* !defined(NETEXPORT_H) */" >> $LSOF_TMP4
      rm -f $LSOF_TMP1 $LSOF_TMP2 $LSOF_TMP3
      echo $LSOF_CFGF | grep /lib/dialects/netbsd/include > /dev/null 2>&1
      if test $? -ne 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/lib/dialects/netbsd/include"
      fi	# }
    fi	# }
    if test $LSOF_NBSD_BUFQH -eq 1	# {
    then

    # Make a local copy of $NETBSD_SYS/sys/bufq.h.

      if test ! -d lib/dialects/netbsd/include	# {
      then
	mkdir lib/dialects/netbsd/include
      fi	# }
      if test ! -d lib/dialects/netbsd/include/sys	# {
      then
	mkdir lib/dialects/netbsd/include/sys
      fi	# }
      cp $NETBSD_SYS/sys/bufq.h lib/dialects/netbsd/include/sys
      echo $LSOF_CFGF | grep lib/dialects/netbsd/include > /dev/null 2>&1
      if test $? -ne 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -I`pwd`lib/dialects/netbsd/include"
      fi	# }
    fi	# }
    if test $LSOF_NBSD_PTYFS -eq 1	# {
    then

    # Make a local copy of $NETBSD_SYS/sys/fs/ptyfs/.

      if test ! -d lib/dialects/netbsd/include	# {
      then
	mkdir lib/dialects/netbsd/include
      fi	# }
      if test ! -d lib/dialects/netbsd/include/fs	# {
      then
	mkdir lib/dialects/netbsd/include/fs
      fi	# }
      rm -rf lib/dialects/netbsd/include/fs/ptyfs
      mkdir lib/dialects/netbsd/include/fs/ptyfs
      cp $NETBSD_SYS/fs/ptyfs/*.h lib/dialects/netbsd/include/fs/ptyfs
      echo $LSOF_CFGF | grep lib/dialects/netbsd/include > /dev/null 2>&1
      if test $? -ne 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/lib/dialects/netbsd/include"
      fi	# }
    fi	# }
    if test $LSOF_NBSD_TMPFS -eq 1     # {
    then

    # Make a local copy of $NETBSD_SYS/sys/fs/tmpfs/tmpfs.h.

      if test ! -d lib/dialects/netbsd/include     # {
      then
       mkdir lib/dialects/netbsd/include
      fi       # }
      if test ! -d lib/dialects/netbsd/include/fs  # {
      then
       mkdir lib/dialects/netbsd/include/fs
      fi       # }
      rm -rf lib/dialects/netbsd/include/fs/tmpfs
      mkdir lib/dialects/netbsd/include/fs/tmpfs
      cp $NETBSD_SYS/fs/tmpfs/tmpfs.h lib/dialects/netbsd/include/fs/tmpfs
      echo $LSOF_CFGF | grep lib/dialects/netbsd/include > /dev/null 2>&1
      if test $? -ne 0 # {
      then
       LSOF_CFGF="$LSOF_CFGF -I`pwd`lib/dialects/netbsd/include"
      fi       # }
    fi # }

    # Generate lockf.h from kern/vfs_lockf.c
    rm -f ./lockf.h
    if test -r ${NETBSD_SYS}/kern/vfs_lockf.c	# {
    then
      # Find the line number of TAILQ_HEAD
      LSOF_TMP1=`grep -n "^TAILQ_HEAD" ${NETBSD_SYS}/kern/vfs_lockf.c | sed 's/\([0-9]*\):.*$/\1/'`
      if test "X$LSOF_TMP1" != "X"	# {
      then
        LSOF_TMP2=0
        # Find the end of struct lockf
        for i in `grep -n "};" ${NETBSD_SYS}/kern/vfs_lockf.c | sed 's/\([0-9]*\):.*/\1/'` # {
        do
          if test $LSOF_TMP2 -eq 0 -a $i -gt $LSOF_TMP1	# {
          then
            LSOF_TMP2=$i
          fi	# }
        done	# }
        if test $LSOF_TMP2 -eq 0	# {
        then
          LSOF_TMP1=""
        else
          cat > ./lockf.h << LOCKF1
/*
* lockf_owner.h -- created by lsof configure script on
LOCKF1
          printf " * " >> ./lockf.h
          date >> ./lockf.h
          cat >> ./lockf.h << LOCKF2
*/

#if	!defined(LOCKF_H)
#define	LOCKF_H

LOCKF2
          ed -s ${NETBSD_SYS}/kern/vfs_lockf.c >> ./lockf.h << LOCKF3
${LSOF_TMP1},${LSOF_TMP2}p
LOCKF3
          if test $? -ne 0	# {
          then
	    LSOF_TMP1=""
          else
	    cat >> ./lockf.h << LOCKF4

#endif	/* defined(LOCKF_H) */
LOCKF4
	  fi	# }
        fi	# }
      fi	# }
    else
      echo "FATAL ERROR: can't read ${NETBSD_SYS}/kern/vfs_lockf.c"
    fi	# }

    if test "X$LSOF_TMP1" != "X" -a "X$LSOF_TMP2" != "X0" # {
    then
      echo "lockf.h creation succeeded."
      LSOF_CFGF="$LSOF_CFGF -DHAS_LOCKF_H"
    else
      echo "lockf.h creation failed (see 00FAQ)"
    fi	# }

    LSOF_CFGL="$LSOF_CFGL -lkvm"
    LSOF_DIALECT_DIR=netbsd
    ;;

# Configure for OpenBSD.  (OpenBSD uses NetBSD dialect sources and version
# numbering.

  openbsd)
    LSOF_TSTKMEM=0
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the OpenBSD version isn't pre-defined, determine it.

      case $LSOF_VSTR in	# {
      1*)
	LSOF_VERS=1020
	echo "!!!WARNING!!!  Unsupported OpenBSD 1.x version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for OpenBSD 1.2"
	;;
      2.5*)
	LSOF_VERS=2050
	;;
      2.6*)
	LSOF_VERS=2060
	;;
      2.7*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=2070
	;;
      2.8*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=2080
	;;
      2.9*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=2090
	;;
      2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=2090
	echo "!!!WARNING!!!  Unsupported OpenBSD 2.x version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for OpenBSD 2.9"
	;;
      3.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3000
	;;
      3.1*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3010
	;;
      3.2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3020
	;;
      3.3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3030
	;;
      3.4*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3040
	;;
      3.5*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3050
	;;
      3.6*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3060
	;;
      3.7*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3070
	;;
      3.8*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3080
	;;
      3.9*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3090
	;;
      3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3090
	echo "!!!WARNING!!!  Unsupported OpenBSD 3.x version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for OpenBSD 3.9"
	;;
      7.2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=7020
	;;
      7.3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=7030
	;;
      *)
	echo "Unknown OpenBSD release: $LSOF_VSTR"
	echo Assuming OpenBSD 3.9
	LSOF_VERS=3090
	;;
      esac	# }
    fi	# }

    # Test for legal OpenBSD version.

    case $LSOF_VERS in	# {
    1020|2050|2060|2070|2080|2090|3000|3010|3020|3030|3040|3050|3060|3070|3080|3090|7020|7030)
      ;;
    *)
      echo "Unknown OpenBSD version: $LSOF_VERS"
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }

    LSOF_CFGF="$LSOF_CFGF -DOPENBSDV=$LSOF_VERS"

    if test -r ${LSOF_INCLUDE}/netinet6/in6.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
    fi	# }

    if test "X$OPENBSD_SYS" = "X"	# {
    then
      OPENBSD_SYS="/sys"
    fi	# }

    if test -d ${OPENBSD_SYS}/miscfs/procfs	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASPROCFS"
    fi	# }

    if test -r ${LSOF_INCLUDE}/sys/pipe.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_SYS_PIPEH"
    fi	# }

    LSOF_DIALECT_DIR=openbsd
    ;;

# Configure for SCO OpenServer.

  osr|osrgcc|sco|scogcc)
    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB=""
    fi	# }
    if test "X$OSR_CFGF" != "X"	# {
    then

    # Adopt LSOF_CFGF from OSR_CFGF in environment.

      LSOF_CFGF=$OSR_CFGF
    fi	# }
    if test "X$OSR_CFGL" != "X"	# {
    then

    # Adopt LSOF_CFGL from OSR_CFGL in environment.

      LSOF_CFGL=$OSR_CFGL
    fi	# }

  # Evaluate compiler specification.

    if test "X$LSOF_CC" = "X"	# {
    then
      if test "X$LSOF_TGT" = "Xosr" -o "X$LSOF_TGT" = "Xsco"	# {
      then
	LSOF_CC=cc
	LSOF_TMP1=1
      else
	LSOF_CC=gcc
	LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
	LSOF_TMP1=2
      fi	# }
    else
	LSOF_TMP1=0
    fi	# }
    LSOF_TGT="osr"

  # Determine version.

    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR="`LANG=C_C.C /bin/uname -X 2>/dev/null | grep Release | sed 's/Release = \(.*\)/\1/'`"
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the SCO OpenServer release version isn't predefined, determine it.

      case $LSOF_VSTR in	# {
      3.2v2.0)
	LSOF_VERS="20"
	;;
      3.2v2.1)
	LSOF_VERS="21"
	;;
      3.2v4.0)
	LSOF_VERS="40"
	;;
      3.2v4.1)
	LSOF_VERS="41"
	;;
      3.2v4.2)
	LSOF_VERS="42"
	;;
      3.2v5.*)
	LSOF_TSTLFLG="-lsocket"
	LSOF_VERS="`echo $LSOF_VSTR | sed 's/3\.2v//; s/\.//g'`"
	;;
      *)
	echo Unknown SCO OpenServer release: $LSOF_VSTR
	echo Assuming 3.2.0 or 3.2.1
	LSOF_VERS="0"
	;;
      esac	# }
    fi	# }

    # Do SCO OpenServer specific stuff.

    case $LSOF_VERS in	# {
    0)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      LSOF_MKC="cp"
      ;;
    20)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      LSOF_MKC="cp"
      ;;
    21)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      LSOF_MKC="cp"
      ;;
    40)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      ;;
    41)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      ;;
    42)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      ;;
    5*)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -belf"
	LSOF_DEBUG="-O3 -Kspace"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lsocket"
      ;;
    *)
      echo "Unsupported SCO OpenServer release: $LSOF_VERS"
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    LSOF_CFGF="$LSOF_CFGF -DOSRV=$LSOF_VERS"
    if test "X$OSR_STATLSTAT" = "X"	# {
    then
      echo "Testing libc.a for statlstat"
      /bin/nm /lib/libc.a | grep statlstat > /dev/null 2>&1
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_STATLSTAT"
      fi	# }
    else
      if test "X$OSR_STATLSTAT" = "XY" -o "X$OSR_STATLSTAT" = "Xy"	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_STATLSTAT"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/fs/nfs/rnode.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_NFS"
    fi	# }
    if test ! -r ${LSOF_INCLUDE}/netdb.h	# {
    then
      LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/osr/include"
    fi	# }
    LSOF_DIALECT_DIR=osr
    ;;

# Configure for Sun Solaris, SunPro C and gcc.

  solaris|solariscc)
    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB=""
    fi	# }
    if test "X$LSOF_CC" = "X"	# {
    then
      if test "X$LSOF_TGT" = "Xsolariscc"	# {
      then
	if test "X$SOLARIS_CCDIR" = "X"	# {
	then
	  SOLARIS_CCDIR="/opt/SUNWspro/bin"
	fi	# }
	if test -x ${SOLARIS_CCDIR}/cc	# {
	then
	  LSOF_CC=${SOLARIS_CCDIR}/cc
	else
	  if test -x /opt/SunStudioExpress/bin/cc	# {
	  then
	    LSOF_CC=/opt/SunStudioExpress/bin/cc
	  else
	    echo "WARNING: no cc in ${SOLARIS_CCDIR}; using cc without path."
	    LSOF_CC=cc
	  fi	# }
	fi	# }
	LSOF_CCV=`$LSOF_CC -V 2>&1 | sed -n 's/^cc: \(.*\)/\1/p'`
      else
	LSOF_CC=gcc
	LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
      fi	# }
    fi	# }
    LSOF_TGT="solaris"
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the Solaris version isn't predefined, determine it.

      case $LSOF_VSTR in	# {
      5.[0-2])
	LSOF_VERS="20300"
	;;
      5.3)
	LSOF_VERS="20300"
	;;
      5.4)
	LSOF_VERS="20400"
	;;
      5.5)
	LSOF_VERS="20500"
	;;
      5.5.1)
	LSOF_VERS="20501"
	;;
      5.6*)
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="20600"
	;;
      5.7*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="70000"
	;;
      5.8*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="80000"
	;;
      5.9*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="90000"
	;;
      5.10*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="100000"
	;;
      5.11*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="110000"
	;;
      *)
	echo Unknown Solaris version: $LSOF_VSTR
	rm -f $LSOF_HLP
	exit 1
      esac	# }
    fi	# }

    # Clear LSOF_UNSUP message for selected Solaris versions.

    case $LSOF_VERS in	# {
    90000|100000|110000)
      LSOF_UNSUP=""
      ;;
    esac	# }

    # Do Solaris version-specific stuff.

    case $LSOF_VERS in	# {
    20300)

      # Solaris patch 101318-32 creates a longer kernel tcp_s structure,
      # and 101318-45 changes the way the vnode's v_filocks member is
      # handled.  The following code creates a symbol definition for
      # patch 101318 whose value is the patch level.  No symbol is defined
      # if the patch level is not greater than zero.

      if test "X$SOLARIS_23P101318" = "X"	# {
      then
	LSOF_PL=`grep -h SUNW_PATCHID=101318 /var/sadm/pkg/SUNWcar*/pkginfo | sed 's/.*-//' | sort -u | tail -1`
	if test "X$LSOF_PL" = "X"	# {
	then
	  LSOF_PL=0
	fi	# }
      else
	LSOF_PL=$SOLARIS_23P101318
      fi	# }
      if test $LSOF_PL -gt 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DP101318=$LSOF_PL"
      fi	# }
      ;;
    20400)
      if test "X$SOLARIS_24P101945" = "X"	# {
      then
	LSOF_PL=`grep -h SUNW_PATCHID=101945 /var/sadm/pkg/SUNWcar*/pkginfo | sed 's/.*-//' | sort -u | tail -1`
	if test "X$LSOF_PL" = "X"	# {
	then
	  LSOF_PL=0
	fi	# }
      else
	LSOF_PL=$SOLARIS_24P101945
      fi	# }
      if test $LSOF_PL -ge 32	# {
      then
	if test "X$SOLARIS_24P102303" = "X"	# {
	then
	  LSOF_PL=`grep -h SUNW_PATCHID=102303 /var/sadm/pkg/SUNWhea*/pkginfo | sed 's/.*-//' | sort -u | tail -1`
	  if test "X$LSOF_PL" = "X"	# {
	  then
	    LSOF_PL=0
	  fi	# }
	else
	  LSOF_PL=$SOLARIS_24P102303
	fi	# }
	if test $LSOF_PL -ge 2	# {
	then
	  echo "WARNING: your Solaris 2.4 system appears to have patches 101945-32 and 102303-2"
	  echo "         installed.  This probably means the NUM_*_VECTORS definitions in"
	  echo "         <sys/auxv.h> don't match the ones used to build your kernel.  Consult"
	  echo "         the Sun Problems section of the 00FAQ file of the lsof distribution"
	  echo "         for more information on how to work around the problem."
	fi	# }
      fi	# }
      ;;
    20500|20501)
      ;;
    20600|70000|80000|90000|100000|110000)
      if test "X$SOLARIS_26PR_GWINDOWS" = "X"	# {
      then
	rm -f ${LSOF_TMPC}.*
	echo "#define _KMEMUSER" > ${LSOF_TMPC}.c
	echo "#include <sys/proc/prdata.h>" >> ${LSOF_TMPC}.c
	echo "int main(){" >> ${LSOF_TMPC}.c
	echo "enum prnodetype p=PR_GWINDOWS;}" >> ${LSOF_TMPC}.c
	echo "Testing prdata.h for PR_GWINDOWS, using $LSOF_CC"
	echo $LSOF_CC | grep gcc > /dev/null
	if test $? -eq 0	# {
	then
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x  > /dev/null 2>&1
	else
	  $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x  > /dev/null 2>&1
	fi	# }
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPR_GWINDOWS"
	fi	# }
      else
	if test "X$SOLARIS_26PR_GWINDOWS" = "XY" -o "X$SOLARIS_26PR_GWINDOWS" = "Xy"	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPR_GWINDOWS"
	fi	# }
      fi	# }
      if test "X$SOLARIS_26PR_LDT" = "X"	# {
      then
	rm -f ${LSOF_TMPC}.*
	echo "#define _KMEMUSER" > ${LSOF_TMPC}.c
	echo "#include <sys/proc/prdata.h>" >> ${LSOF_TMPC}.c
	echo "int main(){" >> ${LSOF_TMPC}.c
	echo "enum prnodetype p=PR_LDT;}" >> ${LSOF_TMPC}.c
	echo "Testing prdata.h for PR_LDT, using $LSOF_CC"
	echo $LSOF_CC | grep gcc > /dev/null
	if test $? -eq 0	# {
	then
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
	else
	  $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1
	fi	# }
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPR_LDT"
	fi	# }
	rm -f ${LSOF_TMPC}.*
      else
	if test "X$SOLARIS_26PR_LDT" = "XY" -o "X$SOLARIS_26PR_LDT" = "Xy"	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPR_LDT"
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 70000	# {
      then

      # Do tests for Solaris 7 and above.

	if test "X$SOLARIS_KERNBITS" = "X"	# {
	then
	  SOLARIS_KERNBITS=`/bin/isainfo -kv`
	fi	# }
	if test "X$SOLARIS_INSTR" = "X"	# {
	then
	  SOLARIS_INSTR=`/bin/isainfo -k`
	fi	#}
	echo $SOLARIS_KERNBITS | grep 64 > /dev/null
	if test $? -eq 0	# {
	then
	  echo $LSOF_CC | grep gcc > /dev/null
	  if test $? -eq 0	# {
	  then

	# Test gcc for 64 bit support.

	    echo "Testing $LSOF_CC for 64 bit support"
	    rm -f ${LSOF_TMPC}.*
	    echo "int main(){}" > ${LSOF_TMPC}.c
	    LSOF_TMP1=""

	# First try gcc's -m64 option -- it's the most current possibility.

	    $LSOF_CC ${LSOF_TMPC}.c -m64 -o ${LSOF_TMPC}.x > /dev/null 2>&1
	    if test $? -eq 0	# {
	    then
	      /bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null
	      if test $? -eq 0	# {
	      then
		LSOF_TMP1="-m64"
	      fi	# }
	    fi	# }
	    rm -f ${LSOF_TMPC}.*
	    if test "X$LSOF_TMP1" = "X"	# {
	    then

	    # Try using the older -mcpu=v9 option with gcc instead of -m64.

	      echo "int main(){}" > ${LSOF_TMPC}.c
	      $LSOF_CC ${LSOF_TMPC}.c -mcpu=v9 -o ${LSOF_TMPC}.x > /dev/null 2>&1
	      if test $? -eq 0	# {
	      then
		/bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null
		if test $? -eq 0	# {
		then
		  LSOF_TMP1="-mcpu=v9"
		fi	# }
	      fi	# }
	      rm -f ${LSOF_TMPC}.*
	    fi	# }
	    if test "X$LSOF_TMP1" = "X"	# {
	    then
	      echo ""
	      echo "!!!WARNING!!!=========!!!WARNING!!!=========!!!WARNING!!!"
	      echo "!                                                       !"
	      echo "! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT  !"
	      echo "! THIS GCC DOESN'T SUPPORT THE BUILDING OF 64 BIT       !"
	      echo "! SOLARIS EXECUTABLES.  LSOF WILL BE CONFIGURED FOR A   !"
	      echo "! 32 BIT KERNEL.                                        !"
	      echo "!                                                       !"
	      echo "!!!WARNING!!!=========!!!WARNING!!!=========!!!WARNING!!!"
	      echo ""
	    else
	      echo ""
	      echo "*********************************"
	      echo "* Configuring for 64 bit kernel *"
	      echo "*********************************"
	      echo ""
	      LSOF_CFGF="$LSOF_CFGF $LSOF_TMP1"
	      LSOF_CINFO="64 bit kernel"
	      LSOF_TSTK64=1
	    fi	# }
	  else

	  # Test Sun compiler for 64 bit support.

	    case $SOLARIS_INSTR in	# {
	    amd64*)
	      LSOF_TMP1="amd64"
	      LSOF_TMP2="amd64"
	      ;;
	    sparc*)
	      LSOF_TMP1="v9"
	      LSOF_TMP2="sparcv9"
	      ;;
	    *)
	      LSOF_TMP1=""
	      ;;
	    esac	# }
	    if test "X$LSOF_TMP1" != "X"	# {
	    then
	      echo "Testing $LSOF_CC for 64 bit $LSOF_TMP2 support"
	      rm -f ${LSOF_TMPC}.*
	      LSOF_TMP3="-xarch=$LSOF_TMP1"
	      echo "int main(){}" > ${LSOF_TMPC}.c
	      LSOF_TMP4=`$LSOF_CC ${LSOF_TMPC}.c $LSOF_TMP3 -o ${LSOF_TMPC}.x 2>&1`
	      if test $? -eq 0	# {
	      then
		/bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null
		if test $? -ne 0	# {
		then
		  LSOF_TMP3=""
		else
		  echo "X$LSOF_TMP4" | grep "use -m64" > /dev/null 2>&1
		  if test $? -eq 0	# {
		  then
		    LSOF_TMP3=-m64
		  fi	# }
		fi	# }
	      fi	# }
	      rm -f ${LSOF_TMPC}.*
	    else
	      LSOF_TMP3=""
	    fi	# }
	    if test "X$LSOF_TMP3" != "X"	# {
	    then
	      echo ""
	      echo "*********************************"
	      echo "* Configuring for 64 bit kernel *"
	      echo "*********************************"
	      echo ""
	      LSOF_CFGF="$LSOF_CFGF $LSOF_TMP3"
	      LSOF_CINFO="64 bit kernel"
	      LSOF_TSTK64=1
	    else
	      echo ""
	      echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!"
	      echo "!"
	      echo "! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT"
	      echo "! THE VERSION OF SUN C AVAILABLE DOESN'T SUPPORT THE"
	      echo "! \"$LSOF_TMP2\" INSTRUCTION SET."
	      echo "!"
	      echo "! LSOF WILL BE CONFIGURED FOR A 32 BIT KERNEL."
	      echo "!"
	      echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!"
	      echo ""
	    fi	# }
	  fi	# }
	else
	  echo ""
	  echo "*********************************"
	  echo "* Configuring for 32 bit kernel *"
	  echo "*********************************"
	  echo ""
	  LSOF_CINFO="32 bit kernel"
	fi	# }
      fi	# }

      # Do tests specific to Solaris 8 and above.

      if test $LSOF_VERS -ge 80000	# {
      then
	if test -r ${LSOF_INCLUDE}/netinet/ip6.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
	fi	# }
      fi	# }

      # Do tests specific to Solaris 9 and above.

      if test $LSOF_VERS -ge 90000	# {
      then
	if test -r ${LSOF_INCLUDE}/sys/socketvar.h	# {
	then
	  grep soua_vp ${LSOF_INCLUDE}/sys/socketvar.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASSOUXSOUA"
	  fi	# }
	fi	# }
	if test $LSOF_VERS -lt 110000	# {
	then

	# Do tests specific to Solaris 9 and 10.

	  if test -r ${LSOF_INCLUDE}/sys/lgrp_user.h      # {
	  then
	    if test -r ${LSOF_INCLUDE}/sys/lgrp.h      # {
	    then
	      grep lgrp_root ${LSOF_INCLUDE}/sys/lgrp_user.h > /dev/null 2>&1
	      if test $? -eq 0	# {
	      then
		grep lgrp_root ${LSOF_INCLUDE}/sys/lgrp.h > /dev/null 2>&1
		if test $? -eq 0
		then
		  LSOF_CFGF="$LSOF_CFGF -DHAS_LGRP_ROOT_CONFLICT"
		fi	# }
	      fi	# }
	    fi	# }
	  fi	# }
	fi	# }
      fi	# }

      # Do tests specific to Solaris 10 and above.

      if test $LSOF_VERS -eq 100000	# {
      then
	if test -r ${LSOF_INCLUDE}/sys/socket_proto.h	# {
	then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_SOCKET_PROTO_H"
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 100000	# {
      then
	if test -r ${LSOF_INCLUDE}/inet/ipclassifier.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_IPCLASSIFIER_H"
	  grep conn_ixa ${LSOF_INCLUDE}/inet/ipclassifier.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_CONN_NEW"
	  fi	#}
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/cred_impl.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_CRED_IMPL_H"

	  # DEBUG -- Begin temporary hack for Solaris 10, build s10_44.

	  grep "c2/audit.h" ${LSOF_INCLUDE}/sys/cred_impl.h > /dev/null
	  if test $? -eq 0	# {
	  then
	    rm -rf `pwd`/dialects/sun/solaris10
	    mkdir `pwd`/dialects/sun/solaris10
	    mkdir `pwd`/dialects/sun/solaris10/c2
	    touch `pwd`/dialects/sun/solaris10/c2/audit.h
	    LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/sun/solaris10"
	  fi	# }

	  # DEBUG -- End temporary hack for Solaris 10, build s10_44.

	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
	then
	  grep v_path ${LSOF_INCLUDE}/sys/vnode.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_V_PATH"
	    LSOF_TSTVPATH=1
	  fi	# }
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/pc_fs.h	# {
	then
	  grep pc_direntpersec ${LSOF_INCLUDE}/sys/fs/pc_fs.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_PC_DIRENTPERSEC"
	  fi	# }
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/aio_req.h	# {
	then
	  grep "struct[ 	]aio_req" ${LSOF_INCLUDE}/sys/aio_req.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_AIO_REQ_STRUCT"
	  fi	# }
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/zone.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASZONES"
      fi	# }

      # Check for Solaris 10 or higher CTF library and things that depend
      # on it.

      if test -r ${LSOF_INCLUDE}/libctf.h	# {
      then
	LSOF_CTFH=1
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/fs/zfs.h	# {
      then
	if test $LSOF_CTFH -eq 1	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_ZFS"
	  LSOF_CTFL=1
	else
	  echo "WARNING: ZFS support not enabled; libctf.h missing."
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 110000	# {
      then

      # Do things specific to Solaris 11 and above.

	if test $LSOF_CTFH -eq 1	# {
	then
	  LSOF_CTFL=1
	else
	  echo "WARNING: socket support not enabled; libctf.h missing."
	fi	# }
	rm -rf ./solaris11
	mkdir ./solaris11
	mkdir ./solaris11/sys
	touch ./solaris11/sys/extdirent.h
	echo "./solaris11/sys/extdirent.h created"
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/solaris11"
	if test -r ${LSOF_INCLUDE}/sys/mutex.h	# {
	then

	# Check <sys/mutex.h> 'for pad_mutex_t;'.

	  grep 'pad_mutex_t;' ${LSOF_INCLUDE}/sys/mutex.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_PAD_MUTEX"
	  fi	# }
	fi	# )
      fi	# }

      # If -lctf was added to LSOF_CFGL, define HAS_LIBCTF.

      if test $LSOF_CTFL -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_LIBCTF"
	LSOF_CFGL="$LSOF_CFGL -lctf"
      fi	# }
      ;;
    *)
      echo "Unsupported Solaris version: $LSOF_VERS"
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    LSOF_CFGF="$LSOF_CFGF -Dsolaris=$LSOF_VERS"

    # Test for <sys/fs/cachefs_fs.h>.

    if test -r ${LSOF_INCLUDE}/sys/fs/cachefs_fs.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASCACHEFS"
    fi	# }


    # Test for <sys/rgm.h>.

    if test -r ${LSOF_INCLUDE}/sys/rgm.h {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_SYS_RGM_H"
    fi  # }

    # Test for <rpc/rpc_tags.h>.

    if test -r ${LSOF_INCLUDE}/rpc/rpc_tags.h {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_RPC_RPC_TAGS_H"
    fi  # }

    # Test for <utmpx.h>

    if test -r ${LSOF_INCLUDE}/utmpx.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASUTMPX"
    fi	# }

    # Test for VSOCK.

    if test "X$SOLARIS_VSOCK" = "X"	# {
    then
      rm -f ${LSOF_TMPC}.*
      echo "#include <sys/vnode.h>" > ${LSOF_TMPC}.c
      echo "int main(){" >> ${LSOF_TMPC}.c
      echo "enum vtype p=VSOCK;}" >> ${LSOF_TMPC}.c
      echo "Testing vnode.h for VSOCK, using $LSOF_CC"
      echo $LSOF_CC | grep gcc > /dev/null
      if test $? -eq 0	# {
      then
	$LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
      else
	$LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1
      fi	# }
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK"
      fi	# }
      rm -f ${LSOF_TMPC}.*
    else
      if test "X$SOLARIS_VSOCK" = "XY" -o "X$SOLARIS_VSOCK" = "Xy"	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK"
      fi	# }
    fi	# }

    # Test for AFS.

    if test -r ${AFS_VICE}/etc/ThisCell	# {
    then
      if test "X$LSOF_SCRIPT_CALL" = "Xno"	# {
      then
	if test -r ./AFSHeaders -a -r ./AFSVersion	# {
	then
	  LSOF_AFS="yes"
	fi	# }
      else
	if test ! -x ./AFSConfig	# {
	then
	  echo "Can't find or execute the AFSConfig script"
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
	./AFSConfig
	if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion	# {
	then
	    LSOF_AFS="yes"
	fi	# }
      fi	# }
      if test "X$LSOF_AFS" = "Xyes"	# {
      then
	if test "X$SUN_AFSAPATHDEF" = "X"	# {
	then
	  ls /usr/vice/etc/modload/libafs > /dev/null 2>&1
	  if test $? -ne 0	# {
	  then
	    LSOF_TMP1=`ls /usr/vice/etc/modload/libafs* 2>/dev/null | wc -l`
	    if test $LSOF_TMP1 -ne 0	# {
	    then
	      SUN_AFSAPATHDEF=`ls -t /usr/vice/etc/modload/libafs* | head -1`
	    fi	# }
	  fi	# }
	fi	# }
	if test "X$SUN_AFSAPATHDEF" != "X"	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DAFSAPATHDEF=\\\"$SUN_AFSAPATHDEF\\\""
	fi	# }
	LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'`
	LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV"
	LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`"
      fi	# }
    fi	# }

    # Test for VxFS.
    #
    # If the location of the VxFS header files hasn't been defined in the
    # environment, establish their likely locations.

    LSOF_TMP2=$SOLARIS_VXFSINCL
    if test -d /opt/VRTS/include	# {
    then
      LSOF_TMP2="$LSOF_TMP2 /opt/VRTS/include"
    fi	# }
    if test -d /opt/VRTSvxfs/include	# {
    then
      LSOF_TMP2="$LSOF_TMP2 /opt/VRTSvxfs/include"
    fi	# }
    LSOF_TMP1=0
    for i in $LSOF_TMP2	# {
    do
      if test -r ${i}/vxfsutil.h	# {
      then
	LSOF_TMP1=1
	SOLARIS_VXFSINCL=$i
	break
      fi	# }
    done	# }
    if test $LSOF_TMP1 -eq 1	# {
    then

    # Warn that VxFS is unsupported.

      LSOF_UNSUP2="WARNING: VxFS is no longer supported by Solaris lsof."

    # The VxFS header files are for VxFS version 3.4 or above.  Enable VxFS
    # for those versions.

      LSOF_CFGF="$LSOF_CFGF -DHASVXFS -DHASVXFSUTIL -I$SOLARIS_VXFSINCL"

    # Determine which libvxfsutil.a is required -- 32 or 64 bit.

      LSOF_TMP2=""			# assume 32 bit
      echo "X$LSOF_CINFO" | grep "^X64" > /dev/null 2>&1
      if test $? -eq 0-a "X$SOLARIS_INSTR" != "X"	# {
      then
	case $SOLARIS_INSTR in	# {
	amd64*)
	  LSOF_TMP2="/amd64"
	  ;;
	sparcv9*)
	  LSOF_TMP2="/sparcv9"
	  ;;
	esac	# }
      fi	# }

    # See if the correct library has been specified and exists.

      if test "X$SOLARIS_VXFSLIB" = "X"	# {
      then
	SOLARIS_VXFSLIB=`dirname $SOLARIS_VXFSINCL`/lib
      fi	# }
      LSOF_TMP3="${SOLARIS_VXFSLIB}${LSOF_TMP2}/libvxfsutil.a"
      if test ! -r $LSOF_TMP3	# {
      then
	echo "!!!FATAL: no VxFS $LSOF_TMP3"
	exit 1
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -L$SOLARIS_VXFSLIB${LSOF_TMP2} -lvxfsutil -ldl"

    # See if the library has the Reverse Name Lookup (RNL) function.

      nm $LSOF_TMP3 | grep vxfs_inotopath > /dev/null 2>&1
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVXFSRNL -DHASVXFSDNLC"
      fi	# }
    else

    # See if there are VxFS header files for VxFS versions below 3.4.

      if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h	# {
      then

      # Define VxFS for VxFS versions below 3.4.  Make additional header
      # file tests.

	LSOF_CFGF="$LSOF_CFGF -DHASVXFS"
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_fs.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_FS_H"
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_sol.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_SOL_H"
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_machdep.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_MACHDEP_H"
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_solaris.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_SOLARIS_H"
	  grep "off32_t;" ${LSOF_INCLUDE}/sys/fs/vx_machdep.h > /dev/null
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASVXFS_OFF32_T"
	  fi	# }
	  grep "off64_t;" ${LSOF_INCLUDE}/sys/fs/vx_solaris.h > /dev/null
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASVXFS_OFF64_T"
	  fi	# }
	  grep "vx_u64_t;" ${LSOF_INCLUDE}/sys/fs/vx_solaris.h > /dev/null
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASVXFS_U64_T"
	  fi	# }
	fi	# }
	egrep "struct[ 	]vx_inode[ 	]\{" ${LSOF_INCLUDE}/sys/fs/vx_inode.h > /dev/null
	# } (dummy '}' to match '{' in above egrep)
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_VX_INODE"
	fi	# }
      fi	# }
    fi	# }

    # Set libraries and dialect subdirectory.

    LSOF_CFGL="$LSOF_CFGL -lkvm -lelf -lsocket -lnsl"
    LSOF_DIALECT_DIR=sun

    # Set local-specific stuff.

    if test "X$LSOF_LOCALSUFFIX" = "XLOCAL"	# {
    then
      LSOF_DOC="\${DESTDIR}/usr/local/man"
    fi	# }
    ;;

# Configure for SCO|Caldera OpenServer Release 6.0.0 and UnixWare.

  osr6|unixware|uw)
    LSOF_TMP1=$LSOF_TGT
    LSOF_TGT="uw"
    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB=""
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -v`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the Openserver Release 6.0.0 or UnixWare version isn't pre-defined,
      # determine it.

      LSOF_VERS=`echo $LSOF_VSTR | sed 's/\([0-9\.]*\).*/\1/; s/\./ /g' | awk '{printf "%d%02d%02d\n", $1, $2, $3;}'`
    fi	# }
    if test $LSOF_TMP1 = "osr6"	# {
    then
      LSOF_CINFO="OSR6 support via UnixWare sources"

    # Convert the OpenServer Release 6.0.0 version number to a UnixWare one.

      case $LSOF_VERS in	# {
      60000)
	LSOF_VERS=70104
	;;
      *)
	echo "Unknown OpenServer Release version: $LSOF_VERS"
	rm -f $LSOF_HLP
	exit 1
      esac	# }
    fi	# }
    LSOF_CFGF="$LSOF_CFGF -DUNIXWAREV=$LSOF_VERS"

    # Do OpenServer Release 6.0.0 and UnixWare version-specific stuff.

    case $LSOF_VERS in	# {
    20100|20101|20102|20103)
      if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVXFS"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lsocket -lnsl -lelf -lgen"
      ;;
    70000|70001|70100|70101|70103|70104)
      LSOF_TSTBIGF=" "
      LSOF_TSTLFLG="-lsocket -lnsl"
      if test $LSOF_VERS -lt 70103	# {
      then
	LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/uw/uw7"
      else	# $LSOF_VERS -ge 70103

      # Process 7.1.3 and above.

	if test -r ${LSOF_INCLUDE}/netinet/in6.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
	fi	# }
	if test $LSOF_VERS -ge 70104	# {
	then

	# Process 7.1.4 and above.

	  LSOF_TMP1=0
	  if test -r ${LSOF_INCLUDE}/netinet/in_pcb.h	# {
	  then
	    grep INKERNEL ${LSOF_INCLUDE}/netinet/in_pcb.h > /dev/null 2>&1
	    if test $? -eq 0	# {
	    then
	      LSOF_TMP1=1
	    fi	# }
	  fi	# }
	  if test $LSOF_TMP1 -eq 0 -a -r ${LSOF_INCLUDE}/netinet/tcp_var.h   # {
	  then
	    grep INKERNEL ${LSOF_INCLUDE}/netinet/tcp_var.h > /dev/null 2>&1
	    if test $? -eq 0	# {
	    then
	      LSOF_TMP1=1
	    fi	# }
	  fi	# }
	  if test $LSOF_TMP1 -eq 1	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_INKERNEL"
	  fi	# }
	fi	# }
      fi	# }
      if test ! -r ${LSOF_INCLUDE}/vm/swap.h -a -r ${LSOF_INCLUDE}/sys/swap.h	# {
      then
	(cd ./dialects/uw/uw7/vm; rm -f swap.h; ln -s ${LSOF_INCLUDE}/sys/swap.h swap.h)
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/fs/vx_gemini.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVXFS"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lsocket -lnsl -lelf -lgen"
      /bin/pkginfo 2> /dev/null | grep -i patch | grep -i ptf7038 > /dev/null
      if test -r ${LSOF_INCLUDE}/sys/file.h	# {
      then
	grep f_open ${LSOF_INCLUDE}/sys/file.h > /dev/null
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_F_OPEN"
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/fs/cdfs_fs.h	# {
      then
	grep "cdfs_LogSecShift;" ${LSOF_INCLUDE}/sys/fs/cdfs_fs.h > /dev/null 2>&1
	if test $? -eq 0	# {
	then
	  LSOF_TMP=`grep "cdfs_LogSecShift;" ${LSOF_INCLUDE}/sys/fs/cdfs_fs.h | sed 's/^[ 	]*\([^ 	]*\).*/\1/'`
	  if test "X$LSOF_TMP" != "X"	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DTYPELOGSECSHIFT=$LSOF_TMP"
	  fi	# }
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/proc.h	# {
      then
	grep p_pgid ${LSOF_INCLUDE}/sys/proc.h > /dev/null
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_P_PGID"
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 70101	# {
      then

	# Do OpenServer Release 6.0.0 and UnixWare 7.1.1 and above tests, as
	# required.

	if test "X$UW_HAS_NSC" = "X"	# {
	then
	  UW_HAS_NSC=N
	  if test -x /bin/node_self	# {
	  then
	    /bin/node_self > /dev/null 2>&1
	    if test $? -eq 0	# {
	    then
	      UW_HAS_NSC=Y
	    fi	# }
	  fi	# }
	fi	# }
	if test "X$UW_HAS_NSC" = "XY" -o "X$UW_HAS_NSC" = "Xy" 	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_UW_NSC"
	  LSOF_CFGL="$LSOF_CFGL -lcluster"
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/nsc_synch.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_UW_CFS"
	fi	# }
      fi	# }
      ;;
    *)
      echo Unsupported UnixWare version: `uname -v`
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    if test -r ${LSOF_INCLUDE}/sys/fs/xnamnode.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASXNAMNODE"
    fi	# }
    LSOF_DIALECT_DIR=uw
    ;;

# Handle unknown abbreviation.

  *)
    echo "Can't configure for $LSOF_TGT."
    cat $LSOF_HLP
    rm -f $LSOF_HLP
    exit 1
    ;;

# End of LSOF_TGT cases

esac	# }

# Do an inventory of the distribution, as required.

if test "X$LSOF_SCRIPT_CALL" = "Xyes" -a ! -r ./.neverInv	# {
then
  if test ! -f ./Inventory	# Want -x, but Ultrix doesn't grok it.	# {
  then
    echo "Can't find Inventory script."
    rm -f $LSOF_HLP
    exit 1
  fi	# }
  ./Inventory
fi	# }

# Make sure target directory exists.

if test ! -d ./lib/dialects/$LSOF_DIALECT_DIR	# {
then
  echo "Can't configure for $LSOF_TGT -- ./lib/dialects/$LSOF_DIALECT_DIR doesn't exist."
  rm -f $LSOF_HLP
  exit 1
fi	# }

# Make sure $LSOF_MK exists in the target directory.

if test ! -r ./lib/dialects/$LSOF_DIALECT_DIR/$LSOF_MK	# {
then
  echo "Can't configure for $LSOF_TGT -- ./lib/dialects/$LSOF_DIALECT_DIR/$LSOF_MK doesn't exist."
  rm -f $LSOF_HLP
  exit 1
fi	# }

# Make sure $LSOF_MKF, $LSOF_SPMKF, or $LSOF_MKF.$LSOF_LOCALSUFFIX) exists
# in the target directory.

if test "X$LSOF_SPMKF" != "X"	# {
then
  LSOF_TMP1=$LSOF_SPMKF
else
  LSOF_TMP1=$LSOF_MKF
fi	# }
if test "X$LSOF_LOCALSUFFIX" != "X"	# {
then
  LSOF_REST=$LSOF_TMP1.$LSOF_LOCALSUFFIX
else
  LSOF_REST=$LSOF_TMP1
fi	# }
if test ! -r ./lib/dialects/$LSOF_DIALECT_DIR/$LSOF_REST	# {
then
  echo "Can't configure for $LSOF_TGT -- ./lib/dialects/$LSOF_DIALECT_DIR/$LSOF_REST doesn't exist."
  rm -f $LSOF_HLP
  exit 1
fi	# }

# If this is FreeBSD, make sure $LSOF_FBSD_ZFS_MKF exists.

if test $LSOF_FBSD_ZFS -eq 1	# {
then
  if test ! ./dialects/$LSOF_DIALECT_DIR/$LSOF_FBSD_ZFS_MKF	# {
  then
    echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR/$LSOF_FBSD_ZFS_MKF doesn't exist."
    rm -f $LSOF_HLP
    exit 1
  fi	# }
fi	# }}

# Make sure $LSOF_VF exists.  Extract the version number from it.

if test ! -r $LSOF_VF	# {
then
  echo "Version number file, ./$LSOF_VF, doesn't exist."
  rm -f $LSOF_HLP
  exit 1
else
  LSOF_VN=`sed "s/.ds VN \(.*\)/\1/" < $LSOF_VF`
fi	# }

# Clean up in advance.

rm -f $LSOF_F $LSOF_MKFC $LSOF_FBSD_ZFS_MKF $LSOF_TSTCFLG $LSOF_TSTCC
rm -f $LSOF_TSTXOC $LSOF_TSTLFF
echo "rm -f $LSOF_F $LSOF_MKFC $LSOF_FBSD_ZFS_MKF $LSOF_TSTCFLG"
echo "rm -f $LSOF_TSTCC $LSOF_TSTXOC $LSOF_TSTLFF"

# Make sure there's a C compiler name.

if test "X$LSOF_CC" = "X"	# {
then
  LSOF_CC=cc
fi	# }

# Do common feature analyses.

# Check for localtime(3) and strftime(3).

rm -f ${LSOF_TMPC}.*
cat > $LSOF_TMPC.c << .LSOF_END_HERE_DOC2
#include <time.h>
int main(){
  time_t cl;
  struct tm *ts;
  char bf[32];
  if ((cl = time(NULL)) == (time_t)-1)
    return(1);
  ts = localtime(&cl);
  if (strftime(bf, sizeof(bf), "%D", ts) != 8)
    return(1);
  if ((bf[2] != '/') || (bf[5] != '/'))
    return (1);
  return(0);
}
.LSOF_END_HERE_DOC2
echo $EO "Testing C library for localtime() and strftime(), using $LSOF_CC ... $EC"
$LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
if test -x ${LSOF_TMPC}.x	# {
then
  ./${LSOF_TMPC}.x
  if test $? -eq 0	# }
  then
    LSOF_CFGF="$LSOF_CFGF -DHAS_STRFTIME"
    echo "present"
  else
    echo "unusable"
  fi	# }
else
  echo "missing"
fi	# }
rm -f ${LSOF_TMPC}.[cox]

# Make the dialect sources.

if test "X$LSOF_MKC" = "X"	# {
then
  LSOF_MKC="ln -s"
fi	# }
LSOF_MKC=$LSOF_MKC ./lib/dialects/$LSOF_DIALECT_DIR/$LSOF_MK $LSOF_TGT $LSOF_VERS || exit 1

# Make $LSOF_MKFC and ${LSOF_LIB}/$LSOF_LIBMKF.

echo "# $LSOF_TGT Makefile for lsof revision $LSOF_VN" > $LSOF_MKFC
echo "" >> $LSOF_MKFC
echo "CC=	$LSOF_CC" >> $LSOF_MKFC
if test "X$LSOF_CCV" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "CCV=	$LSOF_CCV" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_LIB_NO" = "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "LIB=	${LSOF_LIB}/liblsof.a" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_LD" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "LD=	$LSOF_LD" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_CINFO" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "CINFO=	$LSOF_CINFO" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_CFGD" != "X"	# {
then
  echo "CFGD=	$LSOF_CFGD" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_CFGDN" != "X"	# {
then
  echo "CFGDN=	$LSOF_CFGDN" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_ARCH" != "X"	# {
then
  LSOF_CFGF="$LSOF_CFGF -DLSOF_ARCH=\\\"$LSOF_ARCH\\\""
fi	# }
if test "X$LSOF_VSTR" != "X"	# {
then
  LSOF_TMP=`echo $LSOF_VSTR | sed 's/(/\\\\(/g' | sed 's/)/\\\\)/g'`
  LSOF_CFGF="$LSOF_CFGF -DLSOF_VSTR=\\\"$LSOF_TMP\\\""
fi	# }
echo "" >> $LSOF_MKFC
echo "CFGF=	$LSOF_CFGF" >> $LSOF_MKFC
if test "X$LSOF_LIB_NO" = "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "CFGL=	$LSOF_FCFGL -L./$LSOF_LIB -llsof $LSOF_CFGL" >> $LSOF_MKFC
fi	# }
echo "" >> $LSOF_MKFC
if test "X$LSOF_DEBUG" = "X"	# {
then
  LSOF_DEBUG=""
else
  if test "X$LSOF_DEBUG" = "XNo-O"	# {
  then
    LSOF_DEBUG=""
  fi	# }
fi	# }
echo "DEBUG=	$LSOF_DEBUG" >> $LSOF_MKFC
if test "X$LSOF_OPINC" != "X"	# {
then
  LSOF_DINC="$LSOF_DINC $LSOF_OPINC"
fi	# }
if test "X$LSOF_DINC" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "DINC=	$LSOF_DINC" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_DOC" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "DOC=$LSOF_DOC" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_DISTRIBKVM" != "X" -a "X$LSOF_DISTRIBKVM" != "XKVM"	# {
then
  echo "" >> $LSOF_MKFC
  echo "KVM=	$LSOF_DISTRIBKVM" >> $LSOF_MKFC
fi	# }
echo "" >> $LSOF_MKFC
echo "DIALECT_DIR=	$LSOF_DIALECT_DIR" >> $LSOF_MKFC
rm -f ${LSOF_LIB}/$LSOF_LIBMKF
if test "X$LSOF_LIB_NO" = "X"	# {
then
  cp $LSOF_MKFC ${LSOF_LIB}/$LSOF_LIBMKF
fi	# }
cat ./lib/dialects/$LSOF_DIALECT_DIR/$LSOF_REST >> $LSOF_MKFC
if test "X$LSOF_CFLAGS_OVERRIDE" != "X"	# {
then
  sed -i -e 's/^CFLAGS=/override CFLAGS=/' $LSOF_MKFC
fi	# }
if test "X$LSOF_LIB_NO" = "X"	# {
then

  # Put archiving and optional randomizing strings in ${LSOF_LIB}/$LSOF_LIBMKF.
  #
  # Process optional CFLAGS override.
  #
  # Add the library Makefile skeleton section.

  echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF
  echo "DIALECT_DIR=	$LSOF_DIALECT_DIR" >> ${LSOF_LIB}/$LSOF_LIBMKF
  echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF
  if test "X$LSOF_AR" = "X"	# {
  then
    echo "AR=	ar cr \${LIB} \${OBJ}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  else
    echo "AR=	$LSOF_AR \${LIB} \${OBJ}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  fi	# }
  if test "X$LSOF_RANLIB" != "X"	# {
  then
    echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF
    echo "RANLIB=	$LSOF_RANLIB \${LIB}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  fi	# }
  echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF
  if test "X$LSOF_CFLAGS_OVERRIDE" = "X"	# {
  then
    echo "CFLAGS=	\${CDEFS} \${INCL} \${DEBUG}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  else
    echo "override CFLAGS=\${CDEFS} \${INCL} \${DEBUG}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  fi	# }
  echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF
  cat ${LSOF_LIB}/$LSOF_LIBMKFSKEL >> ${LSOF_LIB}/$LSOF_LIBMKF
  echo $LSOF_MKFC and ${LSOF_LIB}/$LSOF_LIBMKF created.
else
  echo $LSOF_MKFC created.
fi	# }

# If this is FreeBSD, create $LSOF_FBSD_ZFS_MKF.

if test $LSOF_FBSD_ZFS -eq 1	# {
then
  rm -f $LSOF_FBSD_ZFS_MKF
  echo "# $LSOF_TGT ZFS Makefile for lsof revision $LSOF_VN" > $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  echo "CC=		$LSOF_CC" >> $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  echo "CFLAGS=	$LSOF_FBSD_ZFS_CFGF" >> $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  if test "X$LSOF_DEBUG" = "X"	# {
  then
    LSOF_DEBUG="-O"
  else
    if test "X$LSOF_DEBUG" = "XNo-O"	# {
    then
      LSOF_DEBUG=""
    fi	# }
  fi	# }
  echo "DEBUG=	$LSOF_DEBUG" >> $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  echo "OPENSOLARIS=	$LSOF_FBSD_ZFS_SYS" >> $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  cat ./dialects/$LSOF_DIALECT_DIR/$LSOF_FBSD_ZFS_MKF >> $LSOF_FBSD_ZFS_MKF
  echo $LSOF_FBSD_ZFS_MKF created.
fi	# }

# Create test cc file.

echo "$LSOF_CC" > $LSOF_TSTCC
echo "$LSOF_TSTCC created"

# Create test cflags file.

echo "-DLT_DIAL_$LSOF_TGT" > $LSOF_TSTCFLG
if test "X$LSOF_TSTBIGF" != "X"	# {
then
  echo "-DLT_BIGF" >> $LSOF_TSTCFLG
  if test "X$LSOF_TSTBIGF" != "X "	# {
  then
    for i in $LSOF_TSTBIGF	# {
    do
      echo "$i" >> $LSOF_TSTCFLG
    done	# }
  fi	# }
fi	# }
if test "X$LSOF_TSTDFLG" != "X"	# {
then
  for i in $LSOF_TSTDFLG	# {
  do
    echo "$i" >> $LSOF_TSTCFLG
  done	# }
fi	# }
echo $LSOF_CC | grep gcc > /dev/null 2>&1
if test $? -eq 0	# {
then
  echo "-DLT_GCC" >> $LSOF_TSTCFLG
else
  echo "-DLT_CC" >> $LSOF_TSTCFLG
fi	# r}
if test $LSOF_TSTKMEM -eq 1	# {
then
  echo "-DLT_KMEM" >> $LSOF_TSTCFLG
fi	# }
if test $LSOF_TSTK64 -eq 1	# {
then
  echo "-DLT_K64" >> $LSOF_TSTCFLG
fi	# }
echo "-DLT_VERS=$LSOF_VERS" >> $LSOF_TSTCFLG
if test $LSOF_TSTVPATH -eq 1	# {
then
  echo "-DLT_VPATH" >> $LSOF_TSTCFLG
fi	# }
echo "$LSOF_TSTCFLG created"

# Create tests loader flags file.

echo $LSOF_TSTLFLG > $LSOF_TSTLFF
echo "$LSOF_TSTLFF created"

# Create test extra objects file.

echo "$LSOF_TSTXO" > $LSOF_TSTXOC
echo "$LSOF_TSTXOC created"

rm -f $LSOF_HLP

# Call Customize, as required.

if test "X$LSOF_SCRIPT_CALL" = "Xyes" -a ! -r ./.neverCust	# {
then
  if test ! -f ./Customize	# {  Want -x, but Ultrix doesn't grok it.
  then
    echo "Can't find Customize script."
    exit 1
  fi	# }
  ./Customize $LSOF_DIALECT_DIR
fi	# }

# Issue unsupported warnings, as appropriate.

if test "X$LSOF_UNSUP" != "X"	# {
then
  echo "$LSOF_UNSUP"
fi	#}
if test "X$LSOF_UNSUP2" != "X"	# {
then
  echo "$LSOF_UNSUP2"
fi	#}
exit 0
